示例#1
0
        public ActionResult Create(MenuFunction obj, bool SaveAndCountinue = false, string 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));
            }
            //ViewBag
            ViewBag.DDLMenu     = GetMenuList();
            ViewBag.IconList    = ListViewCustom.GetListIcon("~/Templates/AwesomeIcon.xml");
            ViewBag.DDLMenuType = FunctionHelper.MenuType();

            ViewBag.GroupID = group;

            if (ModelState.IsValid)
            {
                obj.Id             = Common.GenerateId();
                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);
                obj.Deleted        = false;
                bool isSuccess = _MenuFunctionService.Create(obj);
                if (isSuccess)
                {
                    //For cache
                    CacheLayer.ClearAll();

                    //Write report
                    MessageReport report = new MessageReport(true, FunctionHelper.GetLocalizeDictionary("Home", "notification")["addSuccess"]);
                    WriteLog.Write(report, GetCurrentUser.GetUser(), obj.Id, obj.MenuName, "MenuFunction");

                    if (SaveAndCountinue)
                    {
                        TempData["Success"] = FunctionHelper.GetLocalizeDictionary("Home", "notification")["addSuccess"];
                        return(RedirectToAction("Create", "MenuFunction", new { controllername = obj.ControllerName, parentid = obj.ParentId, menytype = obj.MenuType, grouplist = obj.MenuGroupListId, group = group, ordernu = obj.OrderNumber + 1 }));
                    }
                    else
                    {
                        return(RedirectToAction("Index", new { group = group }));
                    }
                }
                else
                {
                    ModelState.AddModelError("", FunctionHelper.GetLocalizeDictionary("Home", "notification")["ErMenu"]);
                    return(View(obj));
                }
            }

            return(View());
        }
        public ActionResult Create(string controllername, string parentid, string menytype, string grouplist, string ordernu = "1")
        {
            //ViewBag
            ViewBag.DDLMenu        = GetMenuList();
            ViewBag.IconList       = ListViewCustom.GetListIcon("~/Templates/AwesomeIcon.xml");
            ViewBag.DDLMenuType    = FunctionHelper.MenuType();
            ViewBag.controller     = controllername;
            ViewBag.parent         = parentid;
            ViewBag.menytypeValue  = menytype;
            ViewBag.grouplistValue = grouplist;
            ViewBag.ordernuValue   = ordernu;

            ViewBag.urlValue = url;

            return(View());
        }
示例#3
0
        public ActionResult Update(string id, string group = "")
        {
            ViewBag.DDLMenu     = GetMenuList();
            ViewBag.IconList    = ListViewCustom.GetListIcon("~/Templates/AwesomeIcon.xml");
            ViewBag.DDLMenuType = FunctionHelper.MenuType();

            ViewBag.GroupID = group;

            var obj = _MenuFunctionService.getById(id);

            if (obj != null)
            {
                return(View(obj));
            }
            return(View());
        }
        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));
            }
        }
示例#5
0
        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());
        }
        public ActionResult Create(MenuFunction obj, bool SaveAndCountinue = false)
        {
            //ViewBag
            ViewBag.DDLMenu     = GetMenuList();
            ViewBag.IconList    = ListViewCustom.GetListIcon("~/Templates/AwesomeIcon.xml");
            ViewBag.DDLMenuType = FunctionHelper.MenuType();

            ViewBag.urlValue = url;

            if (!ModelState.IsValid)
            {
                return(View(obj));
            }

            obj.Id             = Common.GenerateId();
            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);
            obj.IsDeleted      = false;

            var report = _MenuFunctionService.Create(obj);

            if (report.isSuccess)
            {
                //For cache
                CacheLayer.ClearAll();

                if (SaveAndCountinue)
                {
                    TempData["Success"] = report.Message;

                    return(RedirectToAction("Create", "MenuFunction", new { controllername = obj.ControllerName, parentid = obj.ParentId, menytype = obj.MenuType, ordernu = obj.OrderNumber + 1 }));
                }

                return(RedirectToAction("Index"));
            }
            else
            {
                ModelState.AddModelError("", "Có lỗi xảy ra trong quá trình khởi tạo.");
                return(View(obj));
            }
        }