public JsonResult Edit(EditPurchaseContract model) { model.UpdatedBy = _context.CurrentAccount.AccountId; model.UpdatedByName = _context.CurrentAccount.NickName; _purchaseContractFacade.Edit(model); return(Json(new { success = true })); }
public static List <PurchaseContractItem> ConvertJsonToPurchaseContractItem(this EditPurchaseContract source) { if (string.IsNullOrEmpty(source.Items)) { throw new Exception("商品明细为空"); } var productPriceList = JsonConvert.DeserializeObject <List <PurchaseContractItem> >(source.Items); return(productPriceList); }
public void Edit(EditPurchaseContract model) { var entity = _db.Table.Find <PurchaseContract>(model.Id); if (model.Code != entity.Code) { _service.ValidateContractCode(model.Code); } entity = model.MapTo <PurchaseContract>(entity); entity.AddPurchaseContractItem(model.ConvertJsonToPurchaseContractItem()); entity.UpdatedOn = DateTime.Now; // _service.ValidateContract(entity); _db.Update(entity); _db.Delete <PurchaseContractItem>(n => n.PurchaseContractId == model.Id); _db.Insert <PurchaseContractItem>(entity.Items.ToArray()); var reason = "修改合同"; _processHistoryService.Track(model.UpdatedBy, model.UpdatedByName, (int)entity.Status, entity.Id, FormType.PurchaseContract, reason); _db.SaveChange(); }