public void UpdateCountry(UpdateCountryInput input) { var country = _mapper.Map <Country>(input); country.Id = input.Id; _countryManager.Update(country); }
public async Task <UpdateCountryPayload> UpdateCountryAsync(UpdateCountryInput input, [ScopedService] GeoDbContext context) { var country = await context.Countries.FindAsync(input.Id); country.Name = input.Name; country.Alpha2Code = input.Alpha2Code; country.Alpha3Code = input.Alpha3Code; await context.SaveChangesAsync(); return(new UpdateCountryPayload(country)); }
public IActionResult PutCountry([FromRoute] int id, [FromBody] UpdateCountryInput country) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != country.Id) { return(BadRequest()); } _countryService.UpdateCountry(country); return(Ok()); }