public ActionResult Edit(Category cat) { var dao = new CategoryDao(); if (ModelState.IsValid) { var session = (UserLogin)Session[CommonConstants.USER_SESSION]; cat.ModifiedBy = session.UserName; var culture = Session[CommonConstants.CurrentCulture]; cat.Language = culture.ToString(); var result = dao.Edit(cat); if (result) { SetAlert("Cập nhật thể loại thành công!", "success"); return(RedirectToAction("Index")); } else { ModelState.AddModelError("", "Cập nhật thể loại không thành công!"); } return(RedirectToAction("Index")); } SetViewBag(cat.ParentID); return(View()); }
public ActionResult Edit(int id, string name) { Category category = dao.getByID(id); category.name = name; if (ModelState.IsValid) { dao.Edit(category); return(RedirectToAction("Index")); } else { return(View(category)); } }
public ActionResult Edit(Category category) { if (!ModelState.IsValid) { return(View(category)); } string addStatus = categoryDao.Edit(category); category.ModifiedDate = DateTime.Now; category.ModifiedBy = (Session[Constants.USER_SESSION] as UserLogin).UserID.ToString(); if (addStatus == COMMON_CONSTANTS.EDIT_FAIL) { return(RedirectToAction("Index", "Error")); } return(View(category)); }
public ActionResult Edit(CategoryView model) { CategoryView remodel = new CategoryView(); var actionStatus = new ActionResultHelper(); actionStatus.ActionStatus = ResultSubmit.failed; string errorString = ""; string message = ""; bool IsValid = true; if (ModelState.IsValid) { //var currentCulture = Session[Common.CommonConstants.CurrentCulture]; model.ModifiedBy = CurrentUser.UserID; remodel = _categoryDao.Edit(model, out message); if (remodel != null && String.IsNullOrEmpty(message)) { actionStatus.ActionStatus = ResultSubmit.success; actionStatus.ErrorReason = String.Format(SiteResource.HTML_ALERT_SUCCESS, Resources.MSG_THE_CATEGORY_HAS_UPDATED_SUCCESSFULLY); Session["ACTION_STATUS"] = actionStatus; return(RedirectToAction("Index")); } else { //ModelState.AddModelError("", Resources.InsertCategoryFailed); errorString = Resources.MSG_THE_CATEGORY_HAS_UPDATED_UNSUCCESSFULLY; goto actionError; } } else { IsValid = false; goto actionError; } actionError: if (!IsValid) { actionStatus.ErrorReason = String.Format(SiteResource.HTML_ALERT_ERROR, Resources.MSG_ERROR_ENTER_DATA_FOR_FORM + errorString); Session["ACTION_STATUS"] = actionStatus; } ViewBag.Title = String.Format(Resources.LABEL_UPDATE, model.Name); return(View("Edit", model)); }