Example #1
0
        public void GetListRole(string StoreID, List <string> ListOrganizationId)
        {
            ListRole = new List <SelectListItem>();
            RoleFactory           roleFactory = new RoleFactory();
            List <SelectListItem> slcRole     = new List <SelectListItem>();
            var listRole = roleFactory.GetListRole(StoreID, null, ListOrganizationId);

            foreach (var item in listRole)
            {
                ListRole.Add(new SelectListItem
                {
                    Text  = item.Name,// + " [" + item.StoreName + "]",
                    Value = item.ID
                });
            }
        }
Example #2
0
        public ActionResult UpdateRoles(Guid userId)
        {
            if (!CheckLogin())
            {
                return(RedirectToAction("Login", "User"));
            }
            if (!CheckRole(ERole.Update))
            {
                return(RedirectToAction("Index"));
            }

            List <UserFuncRoleViewModel> root = new List <UserFuncRoleViewModel>();

            var roles = _roleFactory.GetListRole();
            var funcs = _funcFactory.GetListFunction();

            foreach (var item in funcs)
            {
                var userRoles = _userFactory.GetListRole(userId, item.o_function_id);
                List <RoleStatus> roleStatus = new List <RoleStatus>();
                foreach (var role in roles)
                {
                    roleStatus.Add(new RoleStatus()
                    {
                        RoleId   = role.RoleId,
                        RoleName = role.RoleName,
                        IsActive = userRoles.Contains(role.RoleId)
                    });
                }
                root.Add(new UserFuncRoleViewModel()
                {
                    FunctionId   = item.o_function_id,
                    FunctionName = item.function_name,
                    Roles        = roleStatus
                });
            }

            ViewBag.roles  = roles;
            ViewBag.funcs  = funcs;
            ViewBag.userId = userId.ToString();
            return(View(root));
        }