Esempio n. 1
0
        public ActionResult Index()
        {
            List <RolePrivilegeViewModel> model = new List <RolePrivilegeViewModel>();
            var data = _roleService.GetRolePrivileges(new GetPrivilegeByRoleRequest {
                RoleId = this.UserProfile().RoleId
            });

            if (data.IsSuccess && data.Privileges.Count > 0)
            {
                model = data.Privileges.MapTo <RolePrivilegeViewModel>();
            }

            ViewBag.RoleGroups = _roleGroupService.GetRoleGroups(new Services.Requests.RoleGroup.GetRoleGroupsRequest
            {
                Take = -1,
                SortingDictionary = new Dictionary <string, SortOrder> {
                    { "Name", SortOrder.Ascending }
                }
            })
                                 .RoleGroups.Select(x => new SelectListItem
            {
                Text     = x.Name,
                Value    = x.Id.ToString(),
                Selected = this.UserProfile().RoleId == x.Id
            }).ToList();

            ViewBag.RoleId = this.UserProfile().RoleId;
            return(View(model));
        }
Esempio n. 2
0
 public CreateUserViewModel CreateViewModel(CreateUserViewModel viewModel)
 {
     viewModel.RoleGroupList = _roleGroupService.GetRoleGroups(new Services.Requests.RoleGroup.GetRoleGroupsRequest
     {
         Take = -1,
         SortingDictionary = new Dictionary <string, SortOrder> {
             { "Name", SortOrder.Ascending }
         }
     })
                               .RoleGroups.Select(x => new SelectListItem
     {
         Text     = x.Name,
         Value    = x.Id.ToString(),
         Selected = viewModel.RoleId == x.Id ? true : false
     }).ToList();
     viewModel.IsActive            = true;
     viewModel.RolePrivilegeOption = _rolePrivilegeService.GetRolePrivileges(new Services.Requests.Privilege.GetPrivilegeByRoleRequest {
         RoleId = viewModel.RoleId
     }).Privileges.Select(x => new SelectListItem
     {
         Text  = x.Name,
         Value = x.Id.ToString()
     }).ToList();
     return(viewModel);
 }