|  |  |  | 
|---|
|  |  |  | public async Task<WebResponseContent> AddBoxingInfoAsync(DtBoxingInfo boxingInfo) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | WebResponseContent content = new WebResponseContent(); | 
|---|
|  |  |  | // 验证模型里面数据是否合法,如果不合法抛出异常 | 
|---|
|  |  |  | var errors = ValidateModel(boxingInfo); | 
|---|
|  |  |  | if (errors.Count > 0) | 
|---|
|  |  |  | var info = await BaseDal.QueryFirstAsync(x => x.PalletCode == boxingInfo.PalletCode); | 
|---|
|  |  |  | if (!info.IsNullOrEmpty()) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | foreach (var error in errors) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | Console.WriteLine(error.ErrorMessage); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  | string errorMessage = string.Join(",", errors.Select(e => e.ErrorMessage)); | 
|---|
|  |  |  | content.Error(errorMessage); | 
|---|
|  |  |  | content.Error("该托盘已存在组盘"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | else | 
|---|
|  |  |  | { | 
|---|
|  |  |  | var  info = await BaseDal.QueryFirstAsync(x=>x.PalletCode ==  boxingInfo.PalletCode); | 
|---|
|  |  |  | if (!info.IsNullOrEmpty()) | 
|---|
|  |  |  | // 添加组盘信息 | 
|---|
|  |  |  | var result = await BaseDal.AddDataNavAsync(boxingInfo); | 
|---|
|  |  |  | if (result) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | content.Error("该托盘已存在组盘"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | else | 
|---|
|  |  |  | { | 
|---|
|  |  |  | // 添加组盘信息 | 
|---|
|  |  |  | var result = await BaseDal.AddDataNavAsync(boxingInfo); | 
|---|
|  |  |  | if (result) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | content.OK("添加成功", boxingInfo); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | content.OK("添加成功", boxingInfo); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return content; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public override PageGridData<DtBoxingInfo> GetPageData(PageDataOptions options) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | return base.GetPageData(options); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | // 验证模型 | 
|---|
|  |  |  | public static List<ValidationResult> ValidateModel(object model) | 
|---|
|  |  |  | { | 
|---|