| using Masuit.Tools; | 
| using System.ComponentModel.DataAnnotations; | 
|   | 
| namespace WIDESEA_StorageBasicService; | 
|   | 
| public class BoxingInfoService : ServiceBase<DtBoxingInfo, IBoxingInfoRepository>, IBoxingInfoService | 
| { | 
|     public BoxingInfoService(IBoxingInfoRepository BaseDal) : base(BaseDal) | 
|     { | 
|     } | 
|   | 
|     public async Task<WebResponseContent> AddBoxingInfoAsync(DtBoxingInfo boxingInfo) | 
|     { | 
|         WebResponseContent content = new WebResponseContent(); | 
|         var info = await BaseDal.QueryFirstAsync(x => x.PalletCode == boxingInfo.PalletCode); | 
|         if (!info.IsNullOrEmpty()) | 
|         { | 
|             content.Error("该托盘已存在组盘"); | 
|         } | 
|         else | 
|         { | 
|             // 添加组盘信息 | 
|             var result = await BaseDal.AddDataNavAsync(boxingInfo); | 
|             if (result) | 
|             { | 
|                 content.OK("添加成功", boxingInfo); | 
|             } | 
|         } | 
|         return content; | 
|     } | 
|   | 
|     public override PageGridData<DtBoxingInfo> GetPageData(PageDataOptions options) | 
|     { | 
|         return base.GetPageData(options); | 
|     } | 
|   | 
|     // 验证模型 | 
|     public static List<ValidationResult> ValidateModel(object model) | 
|     { | 
|         // 创建一个验证结果列表 | 
|         var validationResults = new List<ValidationResult>(); | 
|         // 创建一个验证上下文 | 
|         var validationContext = new ValidationContext(model, serviceProvider: null, items: null); | 
|   | 
|         // 使用验证器尝试验证模型,并将验证结果添加到验证结果列表中 | 
|         Validator.TryValidateObject(model, validationContext, validationResults, validateAllProperties: true); | 
|   | 
|         // 返回验证结果列表 | 
|         return validationResults; | 
|     } | 
| } |