public async Task <IActionResult> PutCountry(int id, Country country) { if (id != country.Id) { return(BadRequest()); } _context.Entry(country).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!CountryExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> PutCity(int id, City city) { if (id != city.Id) { return(BadRequest()); } _context.Entry(city).State = EntityState.Modified; var cityValidator = new CityValidator(); var resoultValidator = cityValidator.Validate(city); if (!resoultValidator.IsValid) { return(BadRequest(resoultValidator.Errors)); } var result = await _citiesService.PutCity(id, city); if (result) { return(Ok()); } return(NoContent()); }
public async Task <bool> Update(int id, Country country) { _context.Entry(country).State = EntityState.Modified; try { await _context.SaveChangesAsync(); return(true); } catch (DbUpdateConcurrencyException) { return(false); } }
public async Task <bool> PutDistrict(int id, District district) { _context.Entry(district).State = EntityState.Modified; try { await _context.SaveChangesAsync(); return(true); } catch (DbUpdateConcurrencyException) { return(false); } }
public async Task <bool> Update(Region region) { _context.Entry(region).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!RegionExists(region.Id)) { return(false); } throw; } return(true); }