Example #1
0
        public IActionResult Find(int?countryId)
        {
            try
            {
                if (!countryId.HasValue)
                {
                    return(BadRequest("Invalid Input."));
                }
                var result = _countryRepository.Find(countryId);

                if (result != null)
                {
                    _logger.LogInformation($"ID : {countryId} has been successfully found.");
                    return(Ok(result));
                }
                else
                {
                    _logger.LogError("Country ID : {0} was not found.", countryId);
                    return(StatusCode(404, StatusCodes.ReturnStatusObject("Country Not Found.")));
                }
            }
            catch (Exception e)
            {
                _logger.LogError("Failed to located Country. Error - {0}", e.Message);
                return(StatusCode(400, StatusCodes.ReturnStatusObject("Something went wrong.")));
            }
        }