public IActionResult CreateCountry([FromBody] OriginCountryRequest request) { var country = _mapper.Map <OriginCountryRequest, OriginCountry>(request); _originCountryManager.Add(country); _originCountryManager.SaveChanges(); var response = _mapper.Map <OriginCountryResponse>(country); return(CreatedAtAction(nameof(GetCountryById), new { id = country.Id }, response)); }
public IActionResult UpdateCountry([FromRoute] int id, [FromBody] OriginCountryRequest request) { var country = _originCountryManager.FindCountry(id); if (country == null) { return(NotFound("There is no object with such ID in a DataBase. Try another one.")); } var response = _mapper.Map(request, country); _originCountryManager.SaveChanges(); return(Created("", response)); }