public ActionResult Create(Article model) { if (ModelState.IsValid) { model.AddTime = DateTime.Now; model.Status = 0; model.MainContent = HttpUtility.HtmlEncode(model.MainContent); if (string.IsNullOrEmpty(model.Summary)) { model.Summary = ""; } if (string.IsNullOrEmpty(model.Author)) { model.Author = ""; } ErrorCode result = this.articleBusiness.Create(model); if (result == ErrorCode.Success) { TempData["Message"] = "添加文章成功"; return(RedirectToAction("List")); } else { ModelState.AddModelError("", "添加文章失败, " + result.DisplayName()); } } return(View(model)); }
public ActionResult Create(User model) { if (ModelState.IsValid) { string confirm = Request.Form["confirmPassword"]; if (confirm != model.Password) { ModelState.AddModelError("", "两次输入密码不一致"); return(View(model)); } model.Status = 0; ErrorCode result = this.userBusiness.Create(model); if (result == ErrorCode.Success) { TempData["Message"] = "添加用户成功"; return(RedirectToAction("List")); } else { ModelState.AddModelError("", "添加用户失败, " + result.DisplayName()); } } return(View(model)); }
public ActionResult Login(LoginModel model, string returnUrl) { ViewBag.ReturnUrl = returnUrl; if (ModelState.IsValid) { formsService.SignOut(); HttpContext.Session.Clear(); ErrorCode result = this.userBusiness.Login(model.UserName, model.Password); if (result == ErrorCode.Success) { User user = this.userBusiness.Get(model.UserName); HttpCookie cookie = formsService.SignIn(user.UserName, user.UserTypeName(), model.RememberMe); Response.Cookies.Add(cookie); return(RedirectToLocal(returnUrl)); } else { ModelState.AddModelError("", result.DisplayName()); } } return(View(model)); }
public ActionResult Edit(User model) { if (ModelState.IsValid) { ErrorCode result = this.userBusiness.Update(model); if (result == ErrorCode.Success) { TempData["Message"] = "编辑用户成功"; return(RedirectToAction("List")); } else { ModelState.AddModelError("", "编辑用户失败, " + result.DisplayName()); } } return(View(model)); }
public ActionResult Edit(Column model) { if (ModelState.IsValid) { if (string.IsNullOrEmpty(model.Remark)) { model.Remark = ""; } ErrorCode result = this.columnBusiness.Update(model); if (result == ErrorCode.Success) { TempData["Message"] = "编辑栏目成功"; return(RedirectToAction("List")); } else { ModelState.AddModelError("", "编辑栏目失败, " + result.DisplayName()); } } return(View(model)); }