public ActionResult Create(int?roleId) { this.SaveAccessLog("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"] = "role_create"; ViewData["action_block"] = "Roles/block_role_create"; ViewData["data-form"] = TempData["data"]; string roleid = (Request.QueryString["roleid"] == null ? "0" : Request.QueryString["roleid"].ToString()); this.SetConnectionDB(); RoleServices services = new RoleServices(this.DBConnection); BlockDataRoleCreateModel model = new BlockDataRoleCreateModel(); if (ViewData["data-form"] != null) { model = (BlockDataRoleCreateModel)ViewData["data-form"]; } else { model = services.GetEntityById(Int32.Parse(roleid)); } //BlockDataRoleCreateModel model = services.GetEntityById(Int32.Parse(roleid)); this.GetLanguage(); if (model.RoleId > 0) { ViewData["pagename"] = "role_edit"; } Services.Departments.DepartmentServices departmentServices = new Services.Departments.DepartmentServices(this.DBConnection); ViewData["departments"] = departmentServices.GetList(); ViewData["listdepartmentsadmin"] = departmentServices.GetListAdminLogin((string)Session["CodeIsAdmin"]); if (services.ERROR != null) { FileHelper.SaveFile(new { data = model, ERROR = services.ERROR }, this.LOG_FOLDER + "/ERROR_" + this.GetType().ToString() + APIStringHelper.GenerateFileId() + ".txt"); } BlockLangRoleCreateModel blockLang = new BlockLangRoleCreateModel(); BI_Project.Models.UI.BlockModel blockModel = new Models.UI.BlockModel("block_role_create", this.LANGUAGE_OBJECT, blockLang); blockModel.DataModel = model; ViewData["BlockData"] = blockModel; ViewData["CurrentRoleId"] = roleId; ViewData["CurrentOrgId"] = model.DeptID; return(View("~/" + this.THEME_FOLDER + "/" + this.THEME_ACTIVE + "/index.cshtml")); }
//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")); }
//public ActionResult List() //{ // 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_list"; // ViewData["action_block"] = "Menus/block_menu_list"; // this.GetLanguage(); // ViewData["VIEWDATA_LANGUAGE"] = this.LANGUAGE_OBJECT; // BlockMenuListLangModel blockLang = new BlockMenuListLangModel(); // BI_Project.Models.UI.BlockModel blockModel = new Models.UI.BlockModel("block_menu_list", this.LANGUAGE_OBJECT, blockLang); // //blockModel.DataModel = ViewData["block_menu_left_data"]; // blockModel.Hidden = 0; // ViewData["BlockData"] = blockModel; // return View("~/" + this.THEME_FOLDER + "/" + this.THEME_ACTIVE + "/index.cshtml"); //} //lIST public ActionResult List(int?DeptID = null, int?userId = null, int?roleId = null) { if (Session["IsAdmin"] is false) { return(RedirectToAction("Logout", "Home")); } var _deptID = (int)Session["DepartIdUserLogin"]; //DeptID = (int)Session["DepartIdUserLogin"]; if (DeptID == null) { DeptID = _deptID; } //CheckAdminPermission(); SetCommonData(); MenuServices menuServices = new MenuServices(DBConnection); if (!Request.IsAjaxRequest()) { if (null == Session[SESSION_NAME_USERID]) { return(RedirectToAction("Login", "Home")); } if (Session["IsAdmin"] is false) { return(RedirectToAction("Logout", "Home")); } ViewData["pagename"] = "menu_list"; ViewData["action_block"] = "Menus/block_menu_list"; GetLanguage(); ViewData["VIEWDATA_LANGUAGE"] = LANGUAGE_OBJECT; BlockMenuListLangModel blockLang = new BlockMenuListLangModel(); BlockModel blockModel = new BlockModel("block_menu_list", LANGUAGE_OBJECT, blockLang); Services.Departments.DepartmentServices departmentServices = new Services.Departments.DepartmentServices(this.DBConnection); ViewData["departments"] = departmentServices.GetList(); ViewData["listdepartmentsadmin"] = departmentServices.GetListAdminLogin((string)Session["CodeIsAdmin"]); ViewData["BlockData"] = blockModel; SetConnectionDB(); var menuData = menuServices.GetMenusByDepId((int)Session[SESSION_NAME_USERID], DeptID); ViewData["CurrentOrgId"] = DeptID; ViewData["MenuData"] = menuData; return(View("~/" + THEME_FOLDER + "/" + THEME_ACTIVE + "/index.cshtml")); } else { var menuData = menuServices.GetMenusByDepId((int)Session[SESSION_NAME_USERID], DeptID); // lấy danh sách quyền if (userId != null) { var menuUserData = menuServices.GetUserMenusByUserId(userId.Value); foreach (var item in menuData) { var inttt = menuUserData.IndexOf(item.MenuId); if (menuUserData.IndexOf(item.MenuId) != -1) { item.Selected = true; } else { item.Selected = false; } } } else if (roleId != null) { var menuUserData = menuServices.GetRoleMenusByRoleId(roleId.Value); foreach (var item in menuData) { if (menuUserData.IndexOf(item.MenuId) != -1) { item.Selected = true; } else { item.Selected = false; } } } var uiMenuTreeHelper = new UIMenuTreeHelper(menuData); var uiMenuDataJson = uiMenuTreeHelper.BuildMenuToJsonStr(uiMenuTreeHelper.RootId); return(Json((new JavaScriptSerializer()).Deserialize(uiMenuDataJson, typeof(object)), JsonRequestBehavior.AllowGet)); } }
public ActionResult Create() { if (Session["IsAdmin"] == null || (bool)Session["IsAdmin"] == false) { return(RedirectToAction("Logout", "Home")); } this.SetCommonData(); ViewData["pagename"] = "user_create"; ViewData["action_block"] = "Users/block_user_create"; ViewData["data_form"] = TempData["data"]; string id = (Request.QueryString["id"] == null ? "0" : Request.QueryString["id"].ToString()); this.SetConnectionDB(); UserServices services = new UserServices(this.DBConnection); BlockDataUserCreateModel model = new BlockDataUserCreateModel(); if (TempData["data"] != null) { model = (BlockDataUserCreateModel)ViewData["data_form"]; } else { model = services.GetEntityById(Int32.Parse(id)); } ViewData["data_form"] = model; Services.Departments.DepartmentServices departmentServices = new Services.Departments.DepartmentServices(this.DBConnection); ViewData["departments"] = departmentServices.GetList(); ViewData["listdepartmentsadmin"] = departmentServices.GetListAdminLogin((string)Session["CodeIsAdmin"]); ViewData["CurrentUser"] = id; ViewData["currentOrgId"] = model.DeptId; this.GetLanguage(); if (model.UserId > 0) { ViewData["pagename"] = "user_edit"; } BI_Project.Services.Roles.RoleServices roleServices = new Services.Roles.RoleServices(this.DBConnection); model.ListAllRoles = roleServices.GetList(); MenuServices menuServices = new MenuServices(DBConnection); var menuData = menuServices.GetMenusByDepId((int)Session[SESSION_NAME_USERID]); //ViewData["CurrentDeptId"] = deptId; ViewData["MenuData"] = menuData; BlockLangUserCreateModel blockLang = new BlockLangUserCreateModel(); BI_Project.Models.UI.BlockModel blockModel = new Models.UI.BlockModel("block_user_create", this.LANGUAGE_OBJECT, blockLang); blockModel.DataModel = model; ViewData["BlockData"] = blockModel; if (roleServices.ERROR != null) { FileHelper.SaveFile(roleServices.ERROR, this.LOG_FOLDER + "/ERROR_" + this.GetType().ToString() + BI_Project.Helpers.Utility.APIStringHelper.GenerateFileId() + ".txt"); } if (services.ERROR != null) { FileHelper.SaveFile(services.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")); }