public ActionResult Update(MenuFunction obj, string group = "") { //ViewBag ViewBag.IconList = ListViewCustom.GetListIcon("~/Templates/AwesomeIcon.xml"); ViewBag.DDLMenuType = FunctionHelper.MenuType(); ViewBag.DDLMenu = GetMenuList(); ViewBag.GroupID = group; ViewBag.urlValue = url; if (!ModelState.IsValid) { return(View(obj)); } var oldObj = _MenuFunctionService.getById(obj.Id); if (oldObj == null) { return(View(obj)); } oldObj.MenuName = obj.MenuName; oldObj.ParentId = obj.ParentId; oldObj.OrderNumber = obj.OrderNumber; oldObj.MenuType = obj.MenuType; oldObj.Icon = obj.Icon; oldObj.Active = obj.Active; oldObj.ControllerName = obj.ControllerName != null ? obj.ControllerName : string.Format("controller_{0}", obj.Id); oldObj.ActionName = obj.ActionName != null ? obj.ActionName : string.Format("action_{0}", obj.Id); oldObj.Url = string.Format("/{0}/{1}", obj.ControllerName, obj.ActionName); var report = _MenuFunctionService.Update(oldObj); if (report.isSuccess) { CacheLayer.ClearAll(); return(RedirectToAction("Index", new { group = group })); } else { ModelState.AddModelError("", "Có lỗi xảy ra trong quá trình khởi tạo."); return(View(oldObj)); } }
public ActionResult Update(MenuFunction obj, string group = "") { //ViewBag ViewBag.IconList = ListViewCustom.GetListIcon("~/Templates/AwesomeIcon.xml"); ViewBag.DDLMenuType = FunctionHelper.MenuType(); ViewBag.GroupID = group; if (String.IsNullOrEmpty(obj.MenuName) || String.IsNullOrWhiteSpace(obj.MenuName)) { ModelState.AddModelError("", FunctionHelper.GetLocalizeDictionary("Home", "notification")["menu_Name"]); ViewBag.DDLMenu = GetMenuList(); ViewBag.IconList = ListViewCustom.GetListIcon("~/Templates/AwesomeIcon.xml"); ViewBag.DDLMenuType = FunctionHelper.MenuType(); ViewBag.GroupID = group; return(View(obj)); } if (ModelState.IsValid) { obj.ControllerName = obj.ControllerName != null ? obj.ControllerName : string.Format("controller_{0}", obj.Id); obj.ActionName = obj.ActionName != null ? obj.ActionName : string.Format("action_{0}", obj.Id); obj.Url = string.Format("/{0}/{1}", obj.ControllerName, obj.ActionName); bool isSuccess = _MenuFunctionService.Update(obj); ViewBag.DDLMenu = GetMenuList(); if (isSuccess) { CacheLayer.ClearAll(); MessageReport report = new MessageReport(true, FunctionHelper.GetLocalizeDictionary("Home", "notification")["updateSuccess"]); WriteLog.Write(report, GetCurrentUser.GetUser(), obj.Id, obj.MenuName, "MenuFunction"); return(RedirectToAction("Index", new { group = group })); } else { ModelState.AddModelError("", FunctionHelper.GetLocalizeDictionary("Home", "notification")["ErMenu"]); return(View(obj)); } } return(View()); }