public JsonResult Create(CreatePurchaseContract model) { model.CreatedBy = _context.CurrentAccount.AccountId; model.CreatedByName = _context.CurrentAccount.NickName; _purchaseContractFacade.Create(model); return(Json(new { success = true })); }
public static List <PurchaseContractItem> ConvertJsonToPurchaseContractItem(this CreatePurchaseContract source) { if (string.IsNullOrEmpty(source.Items)) { throw new Exception("商品明细为空"); } var productPriceList = JsonConvert.DeserializeObject <List <PurchaseContractItem> >(source.Items); return(productPriceList); }
public void Create(CreatePurchaseContract model) { var entity = new PurchaseContract(); entity = model.MapTo <PurchaseContract>(); entity.AddPurchaseContractItem(model.ConvertJsonToPurchaseContractItem()); entity.UpdatedBy = entity.CreatedBy; _service.ValidateContractCode(entity.Code); // _service.ValidateContract(entity); _db.Insert(entity); _db.SaveChange(); var reason = "创建合同"; entity = _db.Table.Find <PurchaseContract>(n => n.Code == entity.Code); _processHistoryService.Track(model.CreatedBy, model.CreatedByName, (int)entity.Status, entity.Id, FormType.PurchaseContract, reason); _db.SaveChange(); }