public async Task <IActionResult> PutRestaurant(int id, Restaurant restaurant) { if (id != restaurant.Id) { return(BadRequest()); } _context.Entry(restaurant).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!RestaurantExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> PutVarorModel(int id, VarorModel varorModel) { if (id != varorModel.Id) { return(BadRequest()); } _context.Entry(varorModel).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!VarorModelExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> PutRestaurants([FromRoute] int id, [FromBody] Restaurants restaurants) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != restaurants.Id) { return(BadRequest()); } _context.Entry(restaurants).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!RestaurantsExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public void Update(Restaurant restaurant) { var entry = db.Entry(restaurant); // usong for optimistic concurrency-multiple users trying to change same data //give Restaurant object in modified state so changes must be saved for it entry.State = EntityState.Modified; db.SaveChanges(); }
public void UpdateRestaurant(Restaurant res) { _context.Entry(_context.Restaurants.FirstOrDefault(x => x.Id == res.Id)).CurrentValues.SetValues(res); _context.SaveChanges(); }