Esempio n. 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"));
        }
Esempio n. 2
0
        //private string x = SESSION_NAME_USERID;

        public ActionResult Create()
        {
            if (null == Session[this.SESSION_NAME_USERID])
            {
                return(RedirectToAction("Login", "Home"));
            }
            if (Session["IsAdmin"] is false)
            {
                return(RedirectToAction("Logout", "Home"));
            }
            this.SetCommonData();
            ViewData["pagename"]     = "menu_create";
            ViewData["action_block"] = "Menus/block_create_menu";
            ViewData["data-form"]    = TempData["data"];



            string menuId = (Request.QueryString["menuid"] == null ? "0" : Request.QueryString["menuid"].ToString());

            this.SetConnectionDB();
            MenuServices menuServices = new MenuServices(this.DBConnection);

            EntityMenuModel entityMenuModel = new EntityMenuModel();

            entityMenuModel = menuServices.GetMenuModel(menuId);
            Services.Departments.DepartmentServices departmentServices = new Services.Departments.DepartmentServices(this.DBConnection);
            ViewData["CurrentOrgId"]         = entityMenuModel.DeptID;
            ViewData["departments"]          = departmentServices.GetList();
            ViewData["listdepartmentsadmin"] = departmentServices.GetListAdminLogin((string)Session["CodeIsAdmin"]);
            this.GetLanguage();
            ViewData["VIEWDATA_LANGUAGE"] = this.LANGUAGE_OBJECT;


            BlockCreateMenuLangModel blockLang = new BlockCreateMenuLangModel();

            BI_Project.Models.UI.BlockModel blockModel = new Models.UI.BlockModel("block_create_menu", this.LANGUAGE_OBJECT, blockLang);
            blockModel.DataModel  = entityMenuModel;
            ViewData["BlockData"] = blockModel;
            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");
            }
            return(View("~/" + this.THEME_FOLDER + "/" + this.THEME_ACTIVE + "/index.cshtml"));
        }