예제 #1
0
        public CountryCreatingConfirmation CreateCountry(Country country)
        {
            CountryCreatingConfirmation createdCountry = _countryRepository.CreateCountry(country);

            _countryRepository.SaveChanges();
            return(createdCountry);
        }
 public ActionResult <CountryCreatingConfirmationDto> CreateCountry([FromBody] CountryCreatingDto country)
 {
     try
     {
         Country newCountry = mapper.Map <Country>(country);
         CountryCreatingConfirmation createdCountry = _countriesService.CreateCountry(newCountry);
         var location = linkGenerator.GetPathByAction("GetCountrById", "Country", new { countryId = createdCountry.CountryId });
         return(Created(location, mapper.Map <CountryCreatingConfirmationDto>(createdCountry)));
     }
     catch (Exception ex)
     {
         return(StatusCode(StatusCodes.Status500InternalServerError, ex.Message));
     }
 }