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

            var id = CollectionDefinition.BuildId(name);

            var response = await _collectionRepository.GetById(id).ConfigureAwait(false);

            response.Data.ExampleJsonObject = JsonSerializer.Deserialize <object>(response.Data.ExampleJsonObjectString);

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

            _logger.LogInformation($"unable to fetch collection( for {id}");
            return(APIResponse.NotOk(Request.ToRequestString(), "unable to fetch data from elasticsearch", HttpStatusCode.NotFound, response.Id));
        }
示例#2
0
        private async Task <CollectionDefinition> GetCollection(string collectionName)
        {
            var id       = CollectionDefinition.BuildId(collectionName);
            var response = await _collectionRepository.GetById(id).ConfigureAwait(false);

            if (response.Ok)
            {
                return(response.Data);
            }

            return(null);
        }
示例#3
0
        public async Task <IActionResult> GetUserById(Guid id)
        {
            _logger.LogInformation($"Getting the User by Id {id}");

            return(Ok(await _userElasticRepository.GetById(id.ToString())));
        }