Exemplo n.º 1
0
        public void RemoveDish(int?id)
        {
            DishType dishType = _context.DishTypes.Include(x => x.DefaultIngredients).Include(x => x.SubDishType).Where(x => x.DishTypeID == id).FirstOrDefault();
            ICollection <Ingredient> ingredients = dishType.DefaultIngredients;

            dishType.DefaultIngredients = null;
            _context.Update(dishType);

            foreach (Ingredient i in ingredients)
            {
                _context.Ingredients.Remove(i);
            }

            _context.DishTypes.Remove(dishType);
        }
        public async Task <IActionResult> Edit(int id, [Bind("SubDishTypeID,SubType")] SubDishType subDishType)
        {
            if (id != subDishType.SubDishTypeID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(subDishType);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!SubDishTypeExists(subDishType.SubDishTypeID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(subDishType));
        }
Exemplo n.º 3
0
        public async Task <IActionResult> Edit(int id, [Bind("IngredientTypeID,Name,UnitSingular,UnitPlural")] IngredientType ingredientType)
        {
            if (id != ingredientType.IngredientTypeID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(ingredientType);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!IngredientTypeExists(ingredientType.IngredientTypeID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(ingredientType));
        }
Exemplo n.º 4
0
        public IActionResult FinalizesdOrderButton(IFormCollection col, string GuestCode)
        {
            Order order = ctx.Orders.Include(x => x.Selected).Include(x => x.Finalized).Where(x => x.Owner.Code == GuestCode).LastOrDefault();

            if (order == null)
            {
                RedirectToAction("ErrorView");
            }
            if (order.Selected != null)
            {
                if (order.Finalized == null)
                {
                    order.Finalized = new List <Dish>();
                }

                var newfinalized = order.Finalized.Concat(order.Selected);
                order.Finalized = newfinalized.ToList();
                order.Selected.Clear();
                ctx.Update(order);
                ctx.SaveChanges();
            }


            return(RedirectToAction("FinalizedOrder", "MenuCard", new { guestCode = GuestCode }));
        }
Exemplo n.º 5
0
        public async Task <IActionResult> Edit(int id, [Bind("TableID,Capacity")] Table table)
        {
            if (id != table.TableID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(table);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!TableExists(table.TableID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(table));
        }