public async Task <IActionResult> Get([FromQuery] PagingApiModel paging) { var result = await this.usersRepository.GetUsers(new Paging(paging.Page, paging.PageSize)); var apiResult = new PagingResultApiModel <UserApiModel> { Items = result.Items.Select(u => new UserApiModel { Id = u.Id, Username = u.Username }), Paging = PageDetailsApiModel.FromDomain(result.Paging) }; return(this.Ok(apiResult)); }
public async Task <IActionResult> GetUsersInGroup(string clientId, string groupId, [FromQuery] PagingApiModel paging) { if (!this.ModelState.IsValid) { return(this.HttpBadRequest()); } var result = await this.clientUsersRepository.GetUsers(clientId, groupId, new Paging(paging.Page, paging.PageSize)); var userApiModels = new PagingResultApiModel <UserApiModel> { Items = result.Items.Select(u => UserApiModel.FromDomain(u)), Paging = PageDetailsApiModel.FromDomain(result.Paging) }; return(this.Ok(userApiModels)); }
public async Task <IActionResult> GetUsers(string username, string claimType, string claimValue, [FromQuery] PagingApiModel pagingApiModel) { if (!this.ModelState.IsValid) { return(new UnprocessableEntityResult()); } var pagingResult = await this.usersRepository.QueryUsers( username, claimType, claimValue, new Paging(pagingApiModel.Page, pagingApiModel.PageSize)); var result = new PagingResultApiModel <UserApiModel> { Paging = PageDetailsApiModel.FromDomain(pagingResult.Paging), Items = pagingResult.Items.Select(u => UserApiModel.FromDomainModel(u)) }; return(this.Ok(result)); }