コード例 #1
0
        public async Task <IActionResult> GetAllAnimalsByAsync()
        {
            try
            {
                if (!ModelState.IsValid)
                {
                    return(BadRequest(new ResponseErrorDto((int)HttpStatusCode.BadRequest, "Review Required Parameters")));
                }
                var animals = await _animalService.GetAllAnimalsAsync();

                if (animals == null || !animals.Any())
                {
                    return(NoContent());
                }
                return(Ok(new ResponseCollectionDto <ZooAnimalDto>((int)HttpStatusCode.OK, "Ok", animals)));
            }
            catch (ExceptionDto exdto)
            {
                return(StatusCode((int)HttpStatusCode.InternalServerError, new ResponseErrorDto((int)HttpStatusCode.InternalServerError, exdto.UserMessage, exdto.Id)));
            }
            catch (Exception ex)
            {
                var guid = Guid.NewGuid();
                _logger.Log(LogLevel.Error, ex, guid.ToString());
                return(BadRequest(new ResponseErrorDto((int)HttpStatusCode.BadRequest, "Failed to find animal information.", guid)));
            }
        }