45 lines
1.4 KiB
C#
45 lines
1.4 KiB
C#
using Nirvana.Common;
|
|
using Nirvana.Common.ApiBase;
|
|
using Nirvana.Data;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Threading.Tasks;
|
|
using YBDevice.Entity;
|
|
|
|
namespace YBDevice.NApi.DBServices
|
|
{
|
|
/// <summary>
|
|
/// 意见反馈
|
|
/// </summary>
|
|
public partial class AdviceApp : Repository<YB_Advice>
|
|
{
|
|
/// <summary>
|
|
/// 提交意见
|
|
/// </summary>
|
|
/// <param name="model"></param>
|
|
/// <returns></returns>
|
|
public async Task<ResultInfo> SubmitAsync(YB_Advice model)
|
|
{
|
|
if (!Validate.IsValidMobile(model.Phone))
|
|
{
|
|
return new ResultInfo(ResultState.FAIL, "手机号格式不正确");
|
|
}
|
|
if (string.IsNullOrEmpty(model.Content))
|
|
{
|
|
return new ResultInfo(ResultState.SUCCESS, "内容不可为空");
|
|
}
|
|
if(model.Content.Length > 500)
|
|
{
|
|
return new ResultInfo(ResultState.FAIL, "内容不可超过500字");
|
|
}
|
|
using (var dbClient = ReadDbContext.GetInstance())
|
|
{
|
|
model.CreateTime = DateTime.Now;
|
|
await dbClient.Insertable<YB_Advice>(model).ExecuteCommandAsync();
|
|
return new ResultInfo(ResultState.SUCCESS, "感谢您的反馈");
|
|
}
|
|
}
|
|
}
|
|
}
|