コード例 #1
0
 public async Task <ResultModel> GetList(ClientQueryDto clientQueryDto)
 {
     return(await Task.Run(() =>
     {
         try
         {
             var query = _userDatabaseContext.Clients.Where(x => 1 == 1);
             if (!string.IsNullOrWhiteSpace(clientQueryDto.ClientName))
             {
                 query = query.Where(x => x.ClientName.Contains(clientQueryDto.ClientName));
             }
             var list = query.OrderBy(x => x.Id).Select(x => new ClientDto
             {
                 Id = x.Id,
                 Enabled = x.Enabled,
                 ClientId = x.ClientId,
                 RequireClientSecret = x.RequireClientSecret,
                 ClientName = x.ClientName,
                 AccessTokenLifetime = x.AccessTokenLifetime,
                 Created = x.Created,
                 Updated = x.Updated
             });
             var page = PagedList <ClientDto> .ToPagedList(list, clientQueryDto.CurrentPage, clientQueryDto.PageSize);
             return new ResultModel(ResultCode.Success, page);
         }
         catch (Exception ex)
         {
             return new ResultModel(ResultCode.Fail, ex.Message);
         }
     }));
 }
コード例 #2
0
        public async Task <ResultModel <PagedList <ClientDto> > > GetClientPage(ClientQueryDto dto)
        {
            var clientJson = new StringContent(JsonConvert.SerializeObject(dto), Encoding.UTF8, "application/json");
            var response   = await _httpClient.PostAsync($"/api/Client/GetPageList", clientJson);

            if (response.IsSuccessStatusCode)
            {
                return(JsonConvert.DeserializeObject <ResultModel <PagedList <ClientDto> > >(await response.Content.ReadAsStringAsync()));
            }
            return(null);
        }
コード例 #3
0
 public async Task <IActionResult> GetPageList([FromBody] ClientQueryDto dto)
 {
     return(Json(await _clientService.GetList(dto)));
 }