コード例 #1
0
        public ActionResult Edit(int Id)
        {
            int RoleId = this.UserProfile().RoleId;
            var result = _roleService.GetRolePrivilege(new GetPrivilegeRequest
            {
                Id = Id
            });
            var model = new RolePrivilegeViewModel();

            model = result.MapTo <RolePrivilegeViewModel>();

            if (model != null)
            {
                RoleId = model.RoleGroup_Id > 0 ? model.RoleGroup_Id : this.UserProfile().RoleId;
            }

            var privilege = _roleService.GetMenuRolePrivileges(new GetPrivilegeByRolePrivilegeRequest
            {
                RoleId          = RoleId,
                RolePrivilegeId = Id
            });

            model.MenuRolePrivileges = privilege.MenuRolePrivileges.ToList().MapTo <RolePrivilegeViewModel.MenuRolePrivilege>();

            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 = RoleId == x.Id
            }).ToList();


            return(View(model));
        }
コード例 #2
0
        public ActionResult Edit(int Id)
        {
            var model = _roleService.GetRolePrivilege(new GetPrivilegeRequest
            {
                Id = Id
            }).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();


            return(View(model));
        }