public async Task <ResultModel> GetConfigPageList(OcelotConfigQueryDto dto) { return(await Task.Run(() => { try { var query = _userDatabaseContext.OcelotConfigs.Include(x => x.GlobalConfiguration).Where(x => 1 == 1); if (dto.IsEnable != null) { query = query.Where(x => x.IsEnable == dto.IsEnable); } if (!string.IsNullOrWhiteSpace(dto.ConfigName)) { query = query.Where(x => x.ConfigName.Contains(dto.ConfigName)); } var list = query.Select(x => new OcelotConfigDto { Id = x.Id, IsEnable = x.IsEnable, ConfigName = x.ConfigName, GlobalConfiguration = new GlobalConfigurationDto { BaseUrl = x.GlobalConfiguration.BaseUrl, Id = x.GlobalConfiguration.Id, OcelotConfigGuid = x.GlobalConfiguration.OcelotConfigGuid } }); var page = PagedList <OcelotConfigDto> .ToPagedList(list, dto.CurrentPage, dto.PageSize); return new ResultModel(ResultCode.Success, page); } catch (Exception ex) { return new ResultModel(ResultCode.Fail, ex.Message); } })); }
public async Task <IActionResult> GetConfigPageList([FromBody] OcelotConfigQueryDto dto) { return(Json(await _ocelotConfigService.GetConfigPageList(dto))); }
public async Task <ResultModel <PagedList <OcelotConfigDto> > > GetConfigPageList(OcelotConfigQueryDto dto) { var routeJson = new StringContent(JsonConvert.SerializeObject(dto), Encoding.UTF8, "application/json"); var response = await _httpClient.PostAsync($"api/Ocelot/GetConfigPageList", routeJson); if (response.IsSuccessStatusCode) { return(JsonConvert.DeserializeObject <ResultModel <PagedList <OcelotConfigDto> > > (await response.Content.ReadAsStringAsync())); } return(null); }