public ActionResult <BaseResponse> QueryRoleList(RoleListRequest request) { var filters = new List <Expression <Func <Role, bool> > >(); if (!string.IsNullOrWhiteSpace(request.Name)) { filters.Add(x => x.Name.Contains(request.Name) || x.Identify.Contains(request.Name)); } var result = _accountStoreService.QueryRoleListPage(request.PageIndex, request.PageSize, filters, x => x.CreateTime, false, out int total); var list = new List <RoleDto>(); foreach (var role in result) { var roleDto = _mapper.Map <RoleDto>(role); roleDto.Routers = role.RoleRouterRelations.Select(x => _mapper.Map <RouterDto>(x.Router)).Where(x => x.IsDelete == false).OrderBy(x => x.Sort).ToList(); list.Add(roleDto); } var pageData = new PageData <RoleDto>() { PageIndex = request.PageIndex, PageSize = request.PageSize, TotalCount = total, List = list }; return(BaseResponse <PageData <RoleDto> > .GetBaseResponse(pageData)); }
public Role[] GetRoleList(RoleListRequestData request) { VBMCallDispatcher callDispatcher = new VBMCallDispatcher(); RoleListResponse roleListResponse = new RoleListResponse(); RoleListRequest roleListRequest = new RoleListRequest(); if (request == null) { return(null); } try { roleListRequest.UserID = request.UserID; roleListRequest.ChannelCode = Channel.GetChannelID(Channels.BackOffice); roleListResponse = callDispatcher.DispatchAction <RoleListRequest, VeriBranch.Common.MessageDefinitions.RoleListResponse>(TransactionNameConstants.GetRoleListTransaction, MethodTypeEnum.Execute, Channels.SharedAspects, roleListRequest); } catch (Exception ex) { throw new FaultException( ex.Message, new FaultCode("Response Fault")); } if (roleListResponse == null) { return(null); } return(roleListResponse.Role); }
public async Task <IActionResult> GetPageListJson(RoleListRequest paramRequest) { RoleListParam param = paramRequest.param; Pagination pagination = paramRequest.pagination; TData <List <RoleEntity> > obj = await sysRoleBLL.GetPageList(param, pagination); return(Json(obj)); }
public RoleListResponse Execute(RoleListRequest request) { RoleListResponse roleListResponse = new RoleListResponse(); IPagedList <RoleInfo> pagedRoles = ServiceHelper.LoadService <IRoleService>().GetPagedRoles(request.PageNumber, request.PageSize); List <RoleModel> list = pagedRoles.Select <RoleInfo, RoleModel>((Func <RoleInfo, RoleModel>)(m => m.ToModel())).ToList <RoleModel>(); roleListResponse.Roles = new PagedData <RoleModel>((IEnumerable <RoleModel>)list, (IPagedList)pagedRoles); return(roleListResponse); }
/// <summary> /// Replaces role permissions for existing role or creates a new role if <see cref="role"/> /// parameter is null. /// </summary> /// <param name="role">Role to be modified or created (optional)</param> /// <param name="permissions">Permission names array (optional). If empty or absent, the /// <paramref name="role"/> will have no permissions.</param> /// <returns>(<see cref="Role"/>) Role object</returns> public static Role SetRolePermissions(Role role = null, params string[] permissions) { var newName = $"Role {ActionManager.RandomNumber}"; var newRoleSettings = new Role { Id = role == null ? 0 : role.Id, Application = new ApplicationKeyValue { Key = GetApplicationProperties(SidsTenants.CxmApplicationName).ApplicationId }, Name = role == null ? newName : role.Name, Permissions = new List <Permission>(), Status = new Status { Key = 1, Value = "Active" } }; foreach (var permission in permissions) { newRoleSettings.Permissions.Add( new Permission { Key = permission }); } RestController.HttpRequestForm( TestConfig.UserDirectoryBaseUrlApi + UriUserDirectory.RolesSave, Method.POST, Headers, newRoleSettings.ToDictionary()); if (role?.Id > 0) { return(GetRole(role.Id)); } var filter = new RoleListRequest { Pager = new Pager { StartRecordIndex = 0, RecordsPerPage = 2000, SortBy = "Id", SortDesc = false, PageIndex = 0 } }; var response = RestController.HttpRequestForm( TestConfig.UserDirectoryBaseUrlApi + UriUserDirectory.RolesList, Method.POST, Headers, filter.ToDictionary()); var roleId = JsonConvert.DeserializeObject <RoleListResponse>(response) .Rows .Single(x => x.Data.Name == newRoleSettings.Name && x.Data.Application.Value == SidsTenants.CxmApplicationName) .Data .Id; return(roleId == null ? null : GetRole(roleId)); }