public ActionResult CompanyRoleAction(int id, string companyId = "")
        {
            ViewBag.Title = "Role Action";
            int roleID     = id;
            int company_id = Convert.ToInt32(companyId);
            IList <ControllerAction> list = new List <ControllerAction>();
            var listController            = STUtil.GetListController(); //Nedd to check data in respwct of

            ViewBag.action_name = new List <SelectListItem>();
            ViewBag.role_id     = id;
            ViewBag.RoleName    = db.roles.Where(r => r.role_id == id && r.company_id == company_id).FirstOrDefault().role_name;

            foreach (var c in listController)
            {
                string controllerName     = c.Value;
                var    listAllAction      = STUtil.GetListAllActionByController(controllerName);
                var    listAssignedAction = STUtil.GetListActionAssignedByRoleAndController(roleID, controllerName);
                foreach (var aa in listAllAction)
                {
                    ControllerAction ca = new ControllerAction();
                    ca.ControllerName = controllerName;
                    ca.ActionName     = aa.Text;
                    ca.IsAssigned     = listAssignedAction.Where(a => a.Text == aa.Text).Count() > 0 ? true : false;
                    list.Add(ca);
                }
            }
            return(PartialView("_CompanyRoleAction", list));
        }
        public ActionResult MenuRoleAction(int id)
        {
            ViewBag.Title = "Role Action";
            int menuID     = id;
            int company_id = SessionUtil.GetCompanyID();
            IList <ControllerAction> list = new List <ControllerAction>();
            var listController            = STUtil.GetListController(); //Nedd to check data in respwct of

            ViewBag.action_name = new List <SelectListItem>();
            ViewBag.menu_id     = menuID;
            foreach (var c in listController)
            {
                string controllerName     = c.Value;
                var    listAllAction      = STUtil.GetListAllActionByController(controllerName);
                var    listAssignedAction = (from r in db.menu_access_controller_action
                                             where r.menu_id == menuID && r.controller_name == controllerName
                                             orderby r.action_name
                                             select new SelectListItem
                {
                    Value = r.action_name,
                    Text = r.action_name,
                }).ToList();

                foreach (var aa in listAllAction)
                {
                    ControllerAction ca = new ControllerAction();
                    ca.ControllerName = controllerName;
                    ca.ActionName     = aa.Text;
                    ca.IsAssigned     = listAssignedAction.Where(a => a.Text == aa.Text).Count() > 0 ? true : false;
                    list.Add(ca);
                }
            }
            return(PartialView("_MenuRoleAction", list));
        }
        public ActionResult LoadAssignView(int id)
        {
            ViewBag.Title = "Assign View";
            int company_id = Convert.ToInt32(id);

            ViewBag.CompanyId = company_id;
            IList <AssignController> list = new List <AssignController>();
            var listController            = STUtil.GetListController(); //Nedd to check data in respwct of
            var listRoles = db.roles.AsEnumerable().Where(x => x.company_id == company_id).ToList();

            foreach (var rr in listRoles)
            {
                foreach (var c in listController)
                {
                    string controllerName = c.Value;

                    if (controllerName.ToUpper() != "CompanyController".ToUpper() &&
                        controllerName.ToUpper() != "EmailController".ToUpper() &&
                        controllerName.ToUpper() != "JsTree3Controller".ToUpper() &&
                        controllerName.ToUpper() != "ListingXmlController".ToUpper() &&
                        controllerName.ToUpper() != "MastersController".ToUpper() &&
                        controllerName.ToUpper() != "MenuController".ToUpper() &&
                        controllerName.ToUpper() != "RoleController".ToUpper()
                        )
                    {
                        // var listAllAction = STUtil.GetListAllActionByController(controllerName);
                        var listAssignedAction = STUtil.GetListActionAssignedByRoleAndController(rr.role_id, controllerName);
                        AssignController ac    = new AssignController();
                        ac.ControllerName = controllerName;
                        ac.RoleName       = rr.role_name;
                        ac.RoleId         = rr.role_id;
                        ac.IsAssigned     = db.role_action.AsEnumerable().Where(a => a.controller_name == controllerName && a.role_id == rr.role_id).Count() > 0 ? true : false;
                        list.Add(ac);
                    }
                }
            }
            return(PartialView("_CompanyAssignView", list));
        }