public IActionResult PutCountry(Guid id, CountryPutPostDto countryDto) { var country = _countryRepository.GetById(id); if (country == null) { return(NotFound()); } _mapper.Map(countryDto, country); try { _countryRepository.Update(country); } catch (DbUpdateConcurrencyException) { if (!CountryExists(id)) { return(NotFound()); } else { throw; } } return(Ok("Updated")); }
public ActionResult <CountryPutPostDto> PostCountry(CountryPutPostDto countryDto) { var country = _mapper.Map <Country>(countryDto); _countryRepository.Insert(country); return(CreatedAtAction("GetCountry", new { id = country.Id }, _mapper.Map <CountryGetDto>(country))); }