public async Task <IActionResult> PutItem(int id, Item item) { if (id != item.ItemId) { return(BadRequest()); } _context.Entry(item).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ItemExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> PutOrder(int id, Order order) { if (id != order.OrderId) { return(BadRequest()); } _context.Entry(order).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!OrderExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <Drink> Delete(int id) { Drink drinkToDelete = await _context.Drink.FirstAsync(drink => drink.Id == id); _context.Drink.Remove(drinkToDelete); await _context.SaveChangesAsync(); return(drinkToDelete); }
public async Task <Dish> Delete(int id) { Dish dishToDelete = await _context.Dish.FirstAsync(dish => dish.Id == id); _context.Dish.Remove(dishToDelete); await _context.SaveChangesAsync(); return(dishToDelete); }
public async Task <Dish> Put(Dish updateDish) { _context.Update(updateDish); await _context.SaveChangesAsync(); return(updateDish); }