///// <summary> ///// 逻辑删除制造清单明细信息 ///// </summary> ///// <param name="enterinfo"></param> ///// <returns></returns> //public async Task<OperationResult> LogicDelete(params ProManufacturingBOMBillItemInfo[] enterinfos) //{ // enterinfos.CheckNotNull("enterinfos"); // int count = 0; // try // { // ProManufacturingBOMBillItemInfoRepository.UnitOfWork.BeginTransaction(); // count = await ProManufacturingBOMBillItemInfoRepository.RecycleAsync(enterinfos); // ProManufacturingBOMBillItemInfoRepository.UnitOfWork.Commit(); // } // catch (DataException dataException) // { // return new OperationResult(OperationResultType.Error, dataException.Message); // } // catch (OSharpException osharpException) // { // return new OperationResult(OperationResultType.Error, osharpException.Message); // } // List<string> names = new List<string>(); // foreach (var data in enterinfos) // { // names.Add(data.Id.ToString()); // } // return count > 0 // ? new OperationResult(OperationResultType.Success, // names.Count > 0 // ? "Id为“{0}”信息逻辑删除成功".FormatWith(names.ExpandAndToString()) // : "{0}个信息逻辑删除成功".FormatWith(count)) // : new OperationResult(OperationResultType.NoChanged); //} ///// <summary> ///// 逻辑还原制造清单明细信息 ///// </summary> ///// <param name="enterinfo"></param> ///// <returns></returns> //public async Task<OperationResult> LogicRestore(params ProManufacturingBOMBillItemInfo[] enterinfos) //{ // enterinfos.CheckNotNull("enterinfos"); // int count = 0; // try // { // ProManufacturingBOMBillItemInfoRepository.UnitOfWork.BeginTransaction(); // count = await ProManufacturingBOMBillItemInfoRepository.RestoreAsync(enterinfos); // ProManufacturingBOMBillItemInfoRepository.UnitOfWork.Commit(); // } // catch (DataException dataException) // { // return new OperationResult(OperationResultType.Error, dataException.Message); // } // catch (OSharpException osharpException) // { // return new OperationResult(OperationResultType.Error, osharpException.Message); // } // List<string> names = new List<string>(); // foreach (var data in enterinfos) // { // names.Add(data.Id.ToString()); // } // return count > 0 // ? new OperationResult(OperationResultType.Success, // names.Count > 0 // ? "Id为“{0}”的信息逻辑还原成功".FormatWith(names.ExpandAndToString()) // : "{0}个信息逻辑还原成功".FormatWith(count)) // : new OperationResult(OperationResultType.NoChanged); //} /// <summary> /// 更新制造清单明细信息 /// </summary> /// <param name="inputDtos"></param> /// <returns></returns> public async Task <OperationResult> Update(params ProManufacturingBOMBillItemInfoInputDto[] inputDtos) { inputDtos.CheckNotNull("inputDtos"); foreach (var dtoData in inputDtos) { dtoData.ProManufacturingBill = ProManufacturingBillInfoRepository.TrackEntities.Where(m => m.Id == dtoData.ProManufacturingBill_Id).FirstOrDefault(); if (Equals(dtoData.ProManufacturingBill, null)) { return(new OperationResult(OperationResultType.Error, "对应的制造清单不存在,无法保存!")); } dtoData.ProductionProcess = ProductionProcessInfoRepository.TrackEntities.Where(m => m.Id == dtoData.ProductionProcess_Id).FirstOrDefault(); if (Equals(dtoData.ProductionProcess, null)) { return(new OperationResult(OperationResultType.Error, "对应的工序不存在,无法保存!")); } dtoData.Material = MaterialInfoRepository.TrackEntities.Where(m => m.Id == dtoData.Material_Id).FirstOrDefault(); if (Equals(dtoData.Material, null)) { return(new OperationResult(OperationResultType.Error, "对应的物料不存在,无法保存!")); } if (Equals(dtoData.Quantity, null) || dtoData.Quantity <= 0) { return(new OperationResult(OperationResultType.Error, "物料数量应大于0,无法保存!")); } } ProManufacturingBOMBillItemInfoRepository.UnitOfWork.BeginTransaction(); var result = await ProManufacturingBOMBillItemInfoRepository.UpdateAsync(inputDtos); ProManufacturingBOMBillItemInfoRepository.UnitOfWork.Commit(); return(result); }
/// <summary> /// 物理删除制造清单明细信息 /// </summary> /// <param name="ids"></param> /// <returns></returns> public async Task <OperationResult> Delete(params Guid[] ids) { ids.CheckNotNull("ids"); ProManufacturingBOMBillItemInfoRepository.UnitOfWork.BeginTransaction(); var result = await ProManufacturingBOMBillItemInfoRepository.DeleteAsync(ids); ProManufacturingBOMBillItemInfoRepository.UnitOfWork.Commit(); return(result); }
/// <summary> /// 检查实体是否存在 /// </summary> /// <param name="predicate"></param> /// <param name="id"></param> /// <returns></returns> public bool CheckExists(Expression <Func <ProManufacturingBOMBillItemInfo, bool> > predicate, Guid id) { return(ProManufacturingBOMBillItemInfoRepository.CheckExists(predicate, id)); }