コード例 #1
0
        public async Task <IActionResult> Post([FromBody] CountryDTO countryData)
        {
            try
            {
                var newCountry = _mapper.Map <CountryDTO, Country>(countryData);
                newCountry.CreatedDate = DateTimeOffset.UtcNow;
                await _repository.CreateAsync(newCountry);

                return(Ok(newCountry));
            }
            catch (Exception ex)
            {
                return(BadRequest(_errorHandler.JsonErrorMessage((int)HttpStatusCode.BadRequest, ex.Message)));
            }
        }