Exemplo n.º 1
0
        public async Task <IActionResult> DeleteDish(Dishe dish)
        {
            _context.Dishes.Remove(dish);
            await _context.SaveChangesAsync();

            return(RedirectToAction("Index", "Home"));
        }
Exemplo n.º 2
0
        public async Task <IActionResult> AddDish(Dishe dish)
        {
            await _context.Dishes.AddAsync(dish);

            await _context.SaveChangesAsync();

            return(RedirectToAction("Index", "Home"));
        }
Exemplo n.º 3
0
        public async Task <IActionResult> EditDish(Dishe dish)
        {
            var entity = await _context.Dishes.FindAsync(dish.Id);

            if (entity == null)
            {
                await _context.Dishes.AddAsync(dish);
            }
            else
            {
                entity.Name         = dish.Name;
                entity.Price        = dish.Price;
                entity.RestaurantId = dish.RestaurantId;
                entity.Desc         = dish.Desc;
            }
            await _context.SaveChangesAsync();

            return(RedirectToAction("Index", "Home"));
        }