示例#1
0
        public async Task <APIResponse> Get()
        {
            _logger.LogInformation($"get request recieved");

            var response = await _collectionRepository.Query("").ConfigureAwait(false);

            foreach (var item in response.Data)
            {
                item.ExampleJsonObject = JsonSerializer.Deserialize <object>(item.ExampleJsonObjectString);
            }

            if (response.Ok)
            {
                _logger.LogInformation($"fetched all {response.Data.Count} collection(s)");
                return(new APIResponse
                {
                    Request = Request.ToRequestString(),
                    Ok = true,
                    Result = "found",
                    Data = response.Data
                });
            }

            _logger.LogInformation($"no collections to fetch");
            return(APIResponse.NotOk(Request.ToRequestString(), "unable to fetch data to elasticsearch", HttpStatusCode.NoContent, response.Id));
        }