public virtual ActionResult Edit(NavigationModel model) { if (string.IsNullOrEmpty(model.Name)) { ModelState.AddModelError("Name", "Name is required"); } if (string.IsNullOrEmpty(model.Controller)) { ModelState.AddModelError("Controller", "Controller name is required"); } if (model.sort < 0) { ModelState.AddModelError("sort", "Sort can not be null or smaller than 0"); } CMSUserInformation _CMSInformation = new CMSUserInformation(); if (ModelState.IsValid) { CMSNavigation navigation = CMSNavigation.GetByID(model.ID); navigation.Name = model.Name; navigation.Controller = model.Controller; navigation.sort = model.sort; navigation.IsChild = (model.ParentID != null); navigation.ParentID = model.ParentID; navigation.IsHide = model.IsHide; var result = CMSNavigation.Update(navigation, CurrentUser.FullName); if (result.IsSuccess) { NavigationEditPrevilage(model.Previlage, navigation.ID); SetRemoveCurrentNavigationCache(); _CMSInformation.SetRemoveCurrentAllowedControllerActionCache(); return(RedirectToAction(MVC.CMSNavigation.Index("Edit_Success"))); } else { ModelState.AddModelError(result.MessageText, result.MessageText); } } GetListNavigationParent(); GetListPrevilege(); return(View()); }
public virtual ActionResult Add(NavigationModel model) { CMSUserInformation _CMSInformation = new CMSUserInformation(); if (string.IsNullOrEmpty(model.Name)) { ModelState.AddModelError("Name", "Name is required"); } if (string.IsNullOrEmpty(model.Controller)) { ModelState.AddModelError("Controller", "Controller name is required"); } if (model.sort < 0) { ModelState.AddModelError("sort", "Sort can not be null or smaller than 0"); } if (ModelState.IsValid) { CMSNavigation navigation = NavigationModelToCMSNavigation(model); var result = CMSNavigation.Insert(navigation, CurrentUser.FullName); if (result.IsSuccess) { //set navigation previlage NavigationAddPrevilage(model.Previlage, navigation.ID); SetRemoveCurrentNavigationCache(); _CMSInformation.SetRemoveCurrentAllowedControllerActionCache(); return(RedirectToAction(MVC.CMSNavigation.Index("Create_Success"))); } else { ModelState.AddModelError(result.MessageText, result.MessageText); } } GetListNavigationParent(); GetListPrevilege(); return(View()); }