public async Task <IActionResult> PutCountry(long id, Country country) { if (id != country.Id) { return(BadRequest()); } _dbContext.Entry(country).State = EntityState.Modified; try { await _dbContext.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!CountryExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> PutCity(long id, City city) { _logger.LogInformation( SunLogEvents.UpdateItem, SunLogCrudMessages.UpdateById, id, DateTime.UtcNow.ToLongTimeString()); if (id != city.Id) { return(BadRequest()); } _dbContext.Entry(city).State = EntityState.Modified; try { await _dbContext.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!CityExists(id)) { _logger.LogWarning( SunLogEvents.UpdateItemNotFound, SunLogCrudMessages.UpdateByIdNotFound, id, DateTime.UtcNow.ToLongTimeString()); return(NotFound()); } else { throw; } } return(NoContent()); }