public IActionResult Create(DishType newDishType)
        {
            newDishType.DefaultIngredients = new List <Ingredient>();
            if (ModelState.IsValid)
            {
                ctx.DishTypes.Add(newDishType);
                ctx.SaveChanges();

                return(RedirectToAction("Customize"));
            }
            else
            {
                return(View(newDishType));
            }
        }
Пример #2
0
        public IActionResult AddGuest(int?tableNo)
        {
            if (tableNo == null)
            {
                return(RedirectToAction("ErrorView"));
            }

            //await DBCreationTask;

            //
            DBCreationTask.Wait();

            //TODO: add guest here

            //Created new object for a guest

            Guest g = new Guest();

            ctx.Guests.Add(g);
            ctx.SaveChanges();
            string guestCode = Guest.GenerateGuestCode(g.GuestID);

            g.Code = guestCode;

            ctx.Guests.ToList();

            //created new order object that has a owner for above guest object
            ctx.Orders.Add(new Order()
            {
                Owner = g
            });
            ctx.SaveChanges();

            ctx.Orders.ToList();
            return(RedirectToAction("Index", new { guestCode = guestCode }));
            //return RedirectToAction("Index", new GuestCodeWithModel<object>(null, guestCode));
        }