/// <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); }
/// <summary> /// 物理删除托盘信息 /// </summary> /// <param name="ids"></param> /// <returns></returns> public async Task <OperationResult> DeleteMatPallets(params Guid[] ids) { ids.CheckNotNull("ids"); MatPalletRepository.UnitOfWork.BeginTransaction(); // OperationResult result = new OperationResult(); // foreach (Guid idsCurrent in ids) { int matwarehouseareaInfoNew2 = MatWareHouseLocationRepository.TrackEntities .Count(m => m.PalletID != null && m.PalletID == idsCurrent); if (matwarehouseareaInfoNew2 == 0) { result = await MatPalletRepository.DeleteAsync(ids); } else { result.Message = "托盘已经被使用,不能删除!"; } } // MatPalletRepository.UnitOfWork.Commit(); return(result); }
/// <summary> /// 物理删除托盘信息 /// </summary> /// <param name="ids"></param> /// <returns></returns> public async Task <OperationResult> DeleteMatPallets(params Guid[] ids) { ids.CheckNotNull("ids"); MatPalletRepository.UnitOfWork.BeginTransaction(); var result = await MatPalletRepository.DeleteAsync(ids); MatPalletRepository.UnitOfWork.Commit(); return(result); }
/// <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)); }