コード例 #1
0
        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());
        }
コード例 #2
0
        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());
        }
コード例 #3
0
        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);
        }
コード例 #4
0
        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);
        }
コード例 #5
0
        public async Task <Dish> Put(Dish updateDish)
        {
            _context.Update(updateDish);
            await _context.SaveChangesAsync();

            return(updateDish);
        }