Exemplo n.º 1
0
        /// <summary>
        /// 增加托盘信息
        /// </summary>
        /// <param name="inputDtos"></param>
        /// <returns></returns>
        public async Task <OperationResult> Add(params MatPalletInfoInputDto[] inputDtos)
        {
            inputDtos.CheckNotNull("inputDtos");
            foreach (var dtoData in inputDtos)
            {
                if (string.IsNullOrEmpty(dtoData.PalletCode))
                {
                    return(new OperationResult(OperationResultType.Error, "请正确填写托盘类型编号,该组数据不被存储。"));
                }
                if (string.IsNullOrEmpty(dtoData.PalletName))
                {
                    return(new OperationResult(OperationResultType.Error, "请正确填写托盘类型名称,该组数据不被存储。"));
                }
                //
                if (MatPalletRepository.CheckExists(x => x.PalletCode == dtoData.PalletCode))
                {
                    return(new OperationResult(OperationResultType.Error, $"托盘类型编号 {dtoData.PalletCode} 的数据已存在,该组数据不被存储。"));
                }
                if (MatPalletRepository.CheckExists(x => x.PalletName == dtoData.PalletName))
                {
                    return(new OperationResult(OperationResultType.Error, $"托盘类型名称 {dtoData.PalletName} 的数据已存在,该组数据不被存储。"));
                }

                if (dtoData.PalletMaxWeight > 1000)
                {
                    return(new OperationResult(OperationResultType.Error, $"托盘最大承重不能大于1000,该组数据不被存储。"));
                }
            }
            MatPalletRepository.UnitOfWork.BeginTransaction();
            var result = await MatPalletRepository.InsertAsync(inputDtos);

            MatPalletRepository.UnitOfWork.Commit();
            //
            return(result);
        }
Exemplo n.º 2
0
 /// <summary>
 /// 检查实体是否存在
 /// </summary>
 /// <param name="predicate"></param>
 /// <param name="id"></param>
 /// <returns></returns>
 public bool CheckMatPalletExists(Expression <Func <MatPalletInfo, bool> > predicate, Guid id)
 {
     return(MatPalletRepository.CheckExists(predicate, id));
 }