Beispiel #1
0
        /// <summary>
        /// 增加产品明细信息
        /// </summary>
        /// <param name="inputDtos"></param>
        /// <returns></returns>
        public async Task <OperationResult> Add(params PlanOrderItemInfoInputDto[] inputDtos)
        {
            inputDtos.CheckNotNull("inputDtos");
            foreach (var dtoData in inputDtos)
            {
                if (string.IsNullOrEmpty(dtoData.OrderItemCode))
                {
                    return(new OperationResult(OperationResultType.Error, "请正确填写订单明细编号!"));
                }
                if (string.IsNullOrEmpty(dtoData.OrderItemName))
                {
                    return(new OperationResult(OperationResultType.Error, "请正确填写订单明细名称!"));
                }
                if (PlanOrderItemInfoRepository.CheckExists(x => x.OrderItemCode == dtoData.OrderItemCode))
                {
                    return(new OperationResult(OperationResultType.Error, "该订单明细编号已存在,无法保存!"));
                }
                if (PlanOrderItemInfoRepository.CheckExists(x => x.OrderItemName == dtoData.OrderItemName))
                {
                    return(new OperationResult(OperationResultType.Error, "该订单明细名称已存在,无法保存!"));
                }
                dtoData.Order = PlanOrderInfoRepository.TrackEntities.Where(m => m.Id == dtoData.Order_Id).FirstOrDefault();
                if (Equals(dtoData.Order, null))
                {
                    return(new OperationResult(OperationResultType.Error, "对应的主订单不存在,无法保存!"));
                }
                dtoData.Product = ProductInfoRepository.TrackEntities.Where(m => m.Id == dtoData.Product_Id).FirstOrDefault();
                if (Equals(dtoData.Product, null))
                {
                    return(new OperationResult(OperationResultType.Error, "对应的产品不存在,无法保存!"));
                }
            }
            PlanOrderItemInfoRepository.UnitOfWork.BeginTransaction();
            var result = await PlanOrderItemInfoRepository.InsertAsync(inputDtos);

            PlanOrderItemInfoRepository.UnitOfWork.Commit();
            return(result);
        }
Beispiel #2
0
 /// <summary>
 /// 检查实体是否存在
 /// </summary>
 /// <param name="predicate"></param>
 /// <param name="id"></param>
 /// <returns></returns>
 public bool CheckExists(Expression <Func <PlanOrderItemInfo, bool> > predicate, Guid id)
 {
     return(PlanOrderItemInfoRepository.CheckExists(predicate, id));
 }