コード例 #1
0
        public async Task <IActionResult> List()
        {
            try
            {
                var countries = await _repository.FindAllAsync();

                if (countries == null)
                {
                    return(Ok(_errorHandler.JsonErrorMessage((int)HttpStatusCode.NotFound)));
                }
                var countryDTO = _mapper.Map <IEnumerable <CountryDTO> >(countries);
                return(Ok(countryDTO));
            }
            catch (Exception ex)
            {
                return(BadRequest(_errorHandler.JsonErrorMessage((int)HttpStatusCode.BadRequest, ex.Message)));
            }
        }