public ActionResult Save(SaveVoucherHistory savemodel) { if (ModelState.IsValid) { if (savemodel.ID == null) { var model = new VoucherHistory { }; _voucherhistoryTask.Add(model); } else { var model = _voucherhistoryTask.GetById((int)savemodel.ID); if (model == null) { return(AlertMsg("参数错误", HttpContext.Request.UrlReferrer.PathAndQuery)); } _voucherhistoryTask.Update(model); } return(AlertMsg("保存成功", HttpContext.Request.UrlReferrer.PathAndQuery)); } return(View(savemodel)); }
public ActionResult Save(int?id) { var model = new SaveVoucherHistory(); if (id != null) { var item = _voucherhistoryTask.GetById((int)id); if (item == null) { return(AlertMsg("参数错误", HttpContext.Request.UrlReferrer.PathAndQuery)); } model = EntityMapper.Map <VoucherHistory, SaveVoucherHistory>(item); } return(View(model)); }