public async Task <IActionResult> GetCustomerById(string id)
        {
            if (!_healthService.IsStateHealthy)
            {
                return(StatusCode(StatusCodes.Status500InternalServerError));
            }
            if (!Guid.TryParse(id, out var result))
            {
                return(BadRequest());
            }

            try
            {
                var resultFromStorage = await _persistentStorageService.GetByExpressionAsync(x => x.Id == result);

                if (resultFromStorage.FirstOrDefault() == null)
                {
                    return(NotFound());
                }
                return(Ok(resultFromStorage.FirstOrDefault()));
            }
            catch
            {
                return(StatusCode(StatusCodes.Status500InternalServerError));
            }
        }
Beispiel #2
0
        public async Task <IActionResult> GetElementByName(string name)
        {
            if (!_healthService.IsStateHealthy)
            {
                return(StatusCode(StatusCodes.Status500InternalServerError));
            }

            try
            {
                var resultFromStorage = await _persistentStorageService.GetByExpressionAsync(x => x.Name.Contains(name));

                return(Ok(resultFromStorage));
            }
            catch
            {
                return(StatusCode(StatusCodes.Status500InternalServerError));
            }
        }