/// <summary> /// 增加订单信息 /// </summary> /// <param name="inputDtos"></param> /// <returns></returns> public async Task <OperationResult> Add(params PlanOrderInfoInputDto[] inputDtos) { inputDtos.CheckNotNull("inputDtos"); foreach (var dtoData in inputDtos) { if (string.IsNullOrEmpty(dtoData.OrderCode)) { return(new OperationResult(OperationResultType.Error, "请正确填写订单编号!")); } if (string.IsNullOrEmpty(dtoData.OrderName)) { return(new OperationResult(OperationResultType.Error, "请正确填写订单名称!")); } if (PlanOrderInfoRepository.CheckExists(x => x.OrderCode == dtoData.OrderCode)) { return(new OperationResult(OperationResultType.Error, "该订单编号已存在,无法保存!")); } if (PlanOrderInfoRepository.CheckExists(x => x.OrderName == dtoData.OrderName)) { return(new OperationResult(OperationResultType.Error, "该订单名称已存在,无法保存!")); } if (Equals(dtoData.DeliveryTime, null) || Equals(dtoData.ExpectedFinishTime, null)) { return(new OperationResult(OperationResultType.Error, "交货时间或预计完成时间不应为空,无法保存!")); } if (dtoData.ExpectedFinishTime < DateTime.Now) { return(new OperationResult(OperationResultType.Error, "预期完成时间小于系统当前时间,无法保存!")); } if (dtoData.DeliveryTime < dtoData.ExpectedFinishTime) { return(new OperationResult(OperationResultType.Error, "预期完成时间大于交货时间,无法保存!")); } } PlanOrderInfoRepository.UnitOfWork.BeginTransaction(); var result = await PlanOrderInfoRepository.InsertAsync(inputDtos); PlanOrderInfoRepository.UnitOfWork.Commit(); return(result); }
/// <summary> /// 检查实体是否存在 /// </summary> /// <param name="predicate"></param> /// <param name="id"></param> /// <returns></returns> public bool CheckExists(Expression <Func <PlanOrderInfo, bool> > predicate, Guid id) { return(PlanOrderInfoRepository.CheckExists(predicate, id)); }