public ActionResult CreateSave(Document model, string returnUrl = "Index") { ViewBag.Path1 = "参数设置"; //检查记录在权限范围内 //end if (ModelState.IsValid) { try { db.Document.Add(model); db.PPSave(); Common.RMOk(this, "记录:" + model + "新建成功!"); return Redirect(Url.Content(returnUrl)); } catch (Exception e) { if (e.InnerException.Message.Contains("Cannot insert duplicate key row")) { ModelState.AddModelError(string.Empty, "相同名称的记录已存在,保存失败!"); } } } ViewBag.ReturnUrl = returnUrl; return View("Create", model); }
public ActionResult RestoreSave(Document record, string returnUrl = "Index") { ViewBag.Path1 = "参数设置"; //检查记录在权限范围内 var result = Common.GetHRAdminDocumentQuery(db, WebSecurity.CurrentUserId, true).Where(a => a.IsDeleted == true).Where(a => a.Id == record.Id).SingleOrDefault(); if (result == null) { Common.RMError(this); return Redirect(Url.Content(returnUrl)); } //end try { result.IsDeleted = false; db.PPSave(); Common.RMOk(this, "记录:" + result + "恢复成功!"); return Redirect(Url.Content(returnUrl)); } catch (Exception e) { Common.RMOk(this, "记录" + result + "恢复失败!" + e.ToString()); } return Redirect(Url.Content(returnUrl)); }
public ActionResult EditSave(Document model, string returnUrl = "Index") { ViewBag.Path1 = "参数设置"; //检查记录在权限范围内 var result = Common.GetHRAdminDocumentQuery(db, WebSecurity.CurrentUserId).Where(a => a.Id == model.Id).SingleOrDefault(); if (result == null) { Common.RMError(this); return Redirect(Url.Content(returnUrl)); } //end if (ModelState.IsValid) { try { result.Name = model.Name; result.Weight = model.Weight; result.TemplatePath = model.TemplatePath; db.PPSave(); Common.RMOk(this, "记录:" + model + "保存成功!"); return Redirect(Url.Content(returnUrl)); } catch (Exception e) { if (e.InnerException.Message.Contains("Cannot insert duplicate key row")) { ModelState.AddModelError(string.Empty, "相同名称的记录已存在,保存失败!"); } } } ViewBag.ReturnUrl = returnUrl; return View("Edit", model); }