public ActionResult EditSave(EditClientPensionCityDocument model, string returnUrl = "Index") { ViewBag.Path1 = "参数设置"; //检查记录在权限范围内 var result = Common.GetHRAdminClientPensionCityDocumentQuery(db, WebSecurity.CurrentUserId).Include(a => a.Documents).Where(a => a.Id == model.ClientPensionCityDocumentId).SingleOrDefault(); if (result == null) { Common.RMError(this); return Redirect(Url.Content(returnUrl)); } //end if (ModelState.IsValid) { try { var documentIds = Common.GetClientDocumentQuery(db, model.ClientId).Where(a => model.DocumentIds.Any(b => b == a.Id)).ToList(); result.Documents = documentIds; result.DocumentNote = model.DocumentNote; db.PPSave(); Common.RMOk(this, "记录:" + result + "保存成功!"); return Redirect(Url.Content(returnUrl)); } catch (Exception e) { ModelState.AddModelError(string.Empty, e.Message); } } ViewBag.ReturnUrl = returnUrl; return View("Edit", model); }
public ActionResult Edit(int id = 0, string returnUrl = "Index") { ViewBag.Path1 = "参数设置"; //检查记录在权限范围内 var result = Common.GetHRAdminClientPensionCityDocumentQuery(db, WebSecurity.CurrentUserId).Include(a => a.Documents).Where(a => a.Id == id).SingleOrDefault(); if (result == null) { Common.RMError(this); return Redirect(Url.Content(returnUrl)); } //end var model = new EditClientPensionCityDocument { ClientPensionCityDocumentId = result.Id, ClientId = result.ClientId, DocumentNote = result.DocumentNote, DocumentIds = result.Documents.Select(a => a.Id).ToList(), }; ViewBag.ReturnUrl = returnUrl; return View(model); }