示例#1
0
        public ActionResult Create(EntityMenuModel menu)
        {
            if (null == Session[this.SESSION_NAME_USERID])
            {
                return(RedirectToAction("Login", "Home"));
            }

            if (Session["IsAdmin"] is false)
            {
                return(RedirectToAction("Logout", "Home"));
            }
            this.SetConnectionDB();


            int          output       = 0;
            MenuServices menuServices = new MenuServices(this.DBConnection);

            output = menuServices.CreateMenu(menu);

            /****************************************RESPONSE FAILE OR SUCCESS******************************************/

            this.GetLanguage();
            BlockCreateMenuLangModel blockLang = new BlockCreateMenuLangModel();

            blockLang.BlockName = "block_menu_create";
            blockLang.SetLanguage(this.LANGUAGE_OBJECT);
            Session["msg_text"] = blockLang.GetMessage(output);
            Session["msg_code"] = output;

            if (menuServices.ERROR != null)
            {
                BI_Project.Helpers.FileHelper.SaveFile(menuServices.ERROR, this.LOG_FOLDER + "/ERROR_" + this.GetType().ToString() + BI_Project.Helpers.Utility.APIStringHelper.GenerateFileId() + ".txt");
            }

            if (menu.MenuId > 0 && output > 0)
            {
                Session["msg_text"] = blockLang.GetLangByPath("messages.block_menu_create.success_edit", this.LANGUAGE_OBJECT);
            }
            if (output == 0)
            {
                Session["msg_text"] = blockLang.GetLangByPath("messages.block_menu_create.error_business_1", this.LANGUAGE_OBJECT);
                //return RedirectToAction("Create?roleid=" + model.RoleId);
            }
            if (output > 0)
            {
                return(RedirectToAction("List"));
            }


            TempData["data"] = menu;
            return(RedirectToAction("Create"));
        }