Esempio n. 1
0
        protected void CancelOrder_Click(object sender, EventArgs e)
        {
            Button cancelOrder = (Button)sender;

            int index = Convert.ToInt32(cancelOrder.CommandArgument.ToString());

            List <OrderPizza> listOrdersPizza = Helper.HelperSession.GetListOrdersPizza(Session);

            OrderPizza orderPizza = listOrdersPizza[index];

            listOrdersPizza.RemoveAt(index);

            Helper.HelperSession.SetListOrdersPizza(Session, listOrdersPizza);

            double partialSum = Helper.HelperSession.GetSumOrderedPizzas(Session);

            partialSum -= orderPizza.Price;

            Helper.HelperSession.SetSumOrderedPizzas(Session, partialSum);

            double totalSum = Properties.Settings.Default.PriceDeliveryAndService + partialSum;

            Helper.HelperSession.SetTotalPriceOrderedPizzas(Session, totalSum);

            Response.Redirect(Request.Url.AbsoluteUri);
        }
Esempio n. 2
0
        protected void BtnOrder_Click(object sender, EventArgs e)
        {
            OfferedPizza      offerPizza = HelperSession.GetOfferPizza(Session);
            List <Ingredient> listIngredientsSelected = HelperSession.GetListIngredientsSelected(Session);

            OrderPizza orderPizza = new OrderPizza(offerPizza.Id_Offered_Pizza, offerPizza.Price, listIngredientsSelected);

            List <OrderPizza> listOrdersPizza = HelperSession.GetListOrdersPizza(Session);

            listOrdersPizza.Add(orderPizza);

            HelperSession.SetListOrdersPizza(Session, listOrdersPizza);

            double partialSum = HelperSession.GetSumOrderedPizzas(Session);

            partialSum += orderPizza.Price;

            HelperSession.SetSumOrderedPizzas(Session, partialSum);

            double totalSum = Properties.Settings.Default.PriceDeliveryAndService + partialSum;

            HelperSession.SetTotalPriceOrderedPizzas(Session, totalSum);

            Response.Redirect("Basket.aspx");
        }
Esempio n. 3
0
        public void Create(OrderModel o)
        {
            // Order
            Order newOrder = new Order();

            newOrder.UserId  = _sa.GetUser(o.User.Email, o.User.Password).UserId;
            newOrder.StoreId = _sa.GetStore(o.StoreName).StoreId;
            // newOrder.StoreName = o.StoreName;
            newOrder.TotalCost = 0M;
            newOrder.OrderDate = DateTime.Now;
            // OrderPizza
            // Pizza
            foreach (var p in o.Pizzas)
            {
                Pizza newPizza = new Pizza();
                newPizza.Cost    = p.Cost;
                newPizza.SizeId  = _sa.GetSize(p.Size).SizeId;
                newPizza.CrustId = _sa.GetCrust(p.Crust).CrustId;
                newPizza.Cost    = _sa.GetSize(p.Size).Price + _sa.GetCrust(p.Crust).Price;
                foreach (var t in p.Toppings)
                {
                    PizzaTopping pt = new PizzaTopping();
                    pt.Pizza     = newPizza;
                    pt.ToppingId = _sa.GetTopping(t).ToppingId;
                    newPizza.PizzaTopping.Add(pt);
                    newPizza.Cost += _sa.GetTopping(t).Price;
                }
                OrderPizza op = new OrderPizza();
                op.Order = newOrder;
                op.Pizza = newPizza;
                newOrder.OrderPizza.Add(op);
                newOrder.TotalCost += newPizza.Cost;
            }
            _sa.CreateOrder(newOrder);
        }
Esempio n. 4
0
        public async Task <IActionResult> PutOrderPizza(int id, OrderPizza orderPizza)
        {
            if (id != orderPizza.Id)
            {
                return(BadRequest());
            }

            _context.Entry(orderPizza).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!OrderPizzaExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Esempio n. 5
0
        public async Task <ActionResult <OrderPizza> > PostOrderPizza(OrderPizza orderPizza)
        {
            _context.OrderPizza.Add(orderPizza);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetOrderPizza", new { id = orderPizza.Id }, orderPizza));
        }
        public async Task <IActionResult> Edit(int id, [Bind("Id,OrderId,PizzaId,Quantity")] OrderPizza orderPizza)
        {
            if (id != orderPizza.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(orderPizza);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!OrderPizzaExists(orderPizza.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["OrderId"] = new SelectList(_context.Orders, "OrderId", "OrderId", orderPizza.OrderId);
            ViewData["PizzaId"] = new SelectList(_context.Pizzas, "PizzaId", "Name", orderPizza.PizzaId);
            return(View(orderPizza));
        }
Esempio n. 7
0
        public IActionResult Create(long pizzaId) //dont need OrderViewModel, can just bind individual components
        {                                         //[Bind("PizzaId,OrderDateTime,StoreId,UserId,OrderPizzaId")] OrderViewModel orderViewModel
          //should get storeId from IActionResult parameters
            //should get userId from IActionResult parameters
            if (ModelState.IsValid)
            {
                // _context.Add(movie);
                // await _context.SaveChangesAsync();

                // Create new instance of Order
                // OrderDateTime : need to create new order instance, will generate new OrderDateTime
                // StoreId : need to create new order instance, initialize this.StoreId = StoreId
                // UserId : need to create new order instance, initialize this.UserId = UserId
                Order order = new Order(1, 1); //HARD CODED, needs to be dynamic

                // OrderPizzaId : need to create new OrderPizza instance, initialize this.OrderId = OrderId && this.PizzaId = PizzaId

                // after creating instances, save them to database using singletons
                OrderSingleton os = new OrderSingleton();
                os.SaveOrderToDb(order);

                OrderPizza          orderPizza = new OrderPizza(order.OrderId, pizzaId);
                OrderPizzaSingleton ops        = new OrderPizzaSingleton();
                ops.SaveOrderPizzaToDb(orderPizza);
                // order of saves matters, else you will get INSERT statement conflicted with the FOREIGN KEY constraint error

                return(RedirectToAction(nameof(Index)));
            }
            return(View());
        }
        public void EditOrderPizza(OrderPizza OrderPizza)
        {
            // would add it if it didn't exist
            _db.Update(OrderPizza);

            // sometimes we need to do it a different way
            //var trackedMovie = _db.Movie.Find(movie.Id);
            //_db.Entry(trackedMovie).CurrentValues.SetValues(movie);
        }
        public bool Post(Order order, Pizza pizza, int amount)
        {
            var op = new OrderPizza();

            op.OrderPizzaId = _opr.Get().Count() + 1;
            op.OrderId      = order.OrderId;
            op.PizzaId      = pizza.PizzaId;
            op.Amount       = amount;
            return(_opr.Post(op));
        }
        public void AddOrderPizza(int order, int?pizza, int quantity)
        {
            var orderPizza = new OrderPizza
            {
                OrderId  = order,
                PizzaId  = pizza,
                Quantity = quantity
            };

            _db.Add(orderPizza);
        }
Esempio n. 11
0
        public bool PostOrderPizza(Order order, Pizza pizza, int amount)
        {
            var op = new OrderPizza();

            op.OrderPizzaId = GetOrderPizzas().Count() + 1;
            op.OrderId      = order.OrderId;
            op.PizzaId      = pizza.PizzaId;
            op.Amount       = amount;

            _db.OrderPizza.Add(op);
            return(_db.SaveChanges() == 1);
        }
        public async Task <IActionResult> Create([Bind("Id,OrderId,PizzaId,Quantity")] OrderPizza orderPizza)
        {
            if (ModelState.IsValid)
            {
                _context.Add(orderPizza);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["OrderId"] = new SelectList(_context.Orders, "OrderId", "OrderId", orderPizza.OrderId);
            ViewData["PizzaId"] = new SelectList(_context.Pizzas, "PizzaId", "Name", orderPizza.PizzaId);
            return(View(orderPizza));
        }
        //order pizza


        public void AddOrderPizza(int?order_id, int?pizza_id)
        {
            // LINQ: First fails by throwing exception,
            // FirstOrDefault fails to just null


            var OrderPizza = new OrderPizza
            {
                OrderId = order_id,
                PizzaId = pizza_id,
            };

            _db.Add(OrderPizza);
            SaveChanges();
        }
Esempio n. 14
0
        // GET: OrderPizzaCustomers1/CreateOrderPizza
        public IActionResult CreateOrderPizza(string Email)
        {
            OrderPizza OrderPizzasList = new OrderPizza
            {
                pizzaTypeBac = "Bacon",
                PriceSbac    = 8,
                PriceMbac    = 12,
                PriceLbac    = 17,

                pizzaTypeSal = "Salami",
                PriceSsal    = 11,
                PriceMsal    = 16,
                PriceLsal    = 19,

                pizzaTypePep = "Pepperoni",
                PriceSpep    = 7,
                PriceMpep    = 11,
                PriceLpep    = 14,

                pizzaTypeMus = "Mushroom",
                PriceSmus    = 10,
                PriceMmus    = 12,
                PriceLmus    = 16,

                pizzaTypeChe = "Cheese",
                PriceSche    = 5,
                PriceMche    = 7,
                PriceLche    = 11,

                pizzaTypeChk  = "Chicken",
                PriceSchk     = 10,
                PriceMchk     = 12,
                PriceLchk     = 16,
                OrderDate     = DateTime.Now,
                customerEmail = Email
            };

            return(View(OrderPizzasList));
        }
Esempio n. 15
0
        public async Task <IActionResult> CreateOrderPizza([Bind("Id,QtySbac,QtyMbac,QtyLbac,QtySsal,QtyMsal,QtyLsal,QtySpep,QtyMpep,QtyLpep,QtySmus,QtyMmus,QtyLmus,QtySche,QtyMche,QtyLche,QtySchk,QtyMchk,QtyLchk,PriceSbac,PriceMbac,PriceLbac,PriceSsal,PriceMsal,PriceLsal,PriceSpep,PriceMpep,PriceLpep,PriceSmus,PriceMmus,PriceLmus,PriceSche,PriceMche,PriceLche,PriceSchk,PriceMchk,PriceLchk,pizzaTypeBac,pizzaTypeSal,pizzaTypePep,pizzaTypeMus,pizzaTypeChe,pizzaTypeChk,customerId,customerEmail,orderId,OrderDate,totalPrice")] OrderPizza orderPizza)
        {
            orderPizza.OrderDate = DateTime.Now;
            #region Set the total price
            orderPizza.totalPrice = (orderPizza.QtySbac * orderPizza.PriceSbac) +
                                    (orderPizza.QtySsal * orderPizza.PriceSsal) +
                                    (orderPizza.QtySpep * orderPizza.PriceSpep) +
                                    (orderPizza.QtySmus * orderPizza.PriceSmus) +
                                    (orderPizza.QtySche * orderPizza.PriceSche) +
                                    (orderPizza.QtySchk * orderPizza.PriceSchk) +
                                    (orderPizza.QtyMbac * orderPizza.PriceMbac) +
                                    (orderPizza.QtyMsal * orderPizza.PriceMsal) +
                                    (orderPizza.QtyMpep * orderPizza.PriceMpep) +
                                    (orderPizza.QtyMmus * orderPizza.PriceMmus) +
                                    (orderPizza.QtyMche * orderPizza.PriceMche) +
                                    (orderPizza.QtyMchk * orderPizza.PriceMchk) +
                                    (orderPizza.QtyLbac * orderPizza.PriceLbac) +
                                    (orderPizza.QtyLsal * orderPizza.PriceLsal) +
                                    (orderPizza.QtyLpep * orderPizza.PriceLpep) +
                                    (orderPizza.QtyLmus * orderPizza.PriceLmus) +
                                    (orderPizza.QtyLche * orderPizza.PriceLche) +
                                    (orderPizza.QtyLchk * orderPizza.PriceLchk);
            #endregion

            var CustId = await _context.Customers.ToListAsync();

            int currCustId;
            if (CustId.Count != 0)
            {
                currCustId = CustId.Max(c => c.Id);
            }
            else
            {
                currCustId = 1;
            }
            //orderPizza.customerId = Convert.ToInt32(currCustId) ;
            return(View("Views/OrderPizzas1/Create.cshtml", orderPizza));
        }
Esempio n. 16
0
 public void SaveOrderPizzaToDb(OrderPizza orderPizza)
 {
     _pr.Post(orderPizza);
 }
 public bool Post(OrderPizza orderPizza)
 {
     _db.OrderPizza.Add(orderPizza);
     return(_db.SaveChanges() == 1);
 }
Esempio n. 18
0
        static void Run()
        {
            bool CanOrder = true;
            //login + save the store visit
            var context = new myDBContext();

            Console.WriteLine("Enter your user ID");
            string CustomerName = Console.ReadLine();
            string StoreName    = "";

            Console.WriteLine("Enter 1 for Domino's, 2 for Pizza Hut");
            string Selection = Console.ReadLine();

            switch (Selection)
            {
            case "1":
                StoreName = "Dominoes";
                break;

            case "2":
                StoreName = "PizzaHut";
                break;
            }
            var CurrentDt = DateTime.Now;
            var Store     = context.Stores.Single(a => a.Name == StoreName);
            var Customer  = context.Customers.SingleOrDefault(a => a.Name == CustomerName);

            if (Customer == null)
            {
                Customer = new Customer()
                {
                    Name               = CustomerName,
                    LastTimeOrdered    = CurrentDt,
                    LastStoreVisited   = Store.Id,
                    LastStoreVisitTime = CurrentDt,
                };
                context.Add(Customer);
                context.SaveChanges();
            }
            else
            {
                if (Store.Id != Customer.LastStoreVisited && CurrentDt < Customer.LastStoreVisitTime.AddHours(24))
                {
                    Console.WriteLine($"You are still locked into {context.Stores.Single(a => a.Id == Customer.LastStoreVisited).Name}");
                    CanOrder = false;
                }
                else if (CurrentDt < Customer.LastTimeOrdered.AddHours(2))
                {
                    Console.WriteLine("You can only order once every 2 hours");
                    CanOrder = false;
                }
                else
                {
                    Customer.LastTimeOrdered    = CurrentDt;
                    Customer.LastStoreVisited   = Store.Id;
                    Customer.LastStoreVisitTime = CurrentDt;
                }
            }
            //finished login
            if (CanOrder)
            {
                var Order = new Order()
                {
                    CustomerId  = Customer.Id,
                    StoreId     = Store.Id,
                    DateAndTime = CurrentDt,
                };
                //this loops and allows the customer to add or complete their order
                Console.WriteLine("Enter 1 to order, 0 if you don't want to order or if you want to finalize your order");
                int     OrderOrNot      = int.Parse(Console.ReadLine());
                decimal OrderTotalPrice = 0;
                int     OrderSizeLimit  = 50;
                decimal PriceLimit      = 250;
                while (OrderOrNot != 0 && --OrderSizeLimit > -1)
                {
                    //SHOULD BE IN a while loop that repeatedly asks if user wants to add another pizza to order
                    //selecting a pizza preset
                    if (OrderOrNot == 1)
                    {
                        Console.WriteLine("Enter 1 for preset Pizza, 2 for custom");
                        int CustomOrPreset = int.Parse(Console.ReadLine());
                        if (CustomOrPreset == 1)
                        {
                            Console.WriteLine("Enter 2 for MeatPizza, 3 for Veggie");
                            int PizzaChoice = int.Parse(Console.ReadLine());
                            var Pizza       = context.Pizzas.FirstOrDefault(p => p.Id == PizzaChoice);
                            if (OrderTotalPrice + Pizza.Price > PriceLimit)
                            {
                                OrderOrNot = 0;
                                Console.WriteLine("You've exceed the order price limit, discarding the last selected pizza");
                            }
                            else
                            {
                                var OrderPizza = new OrderPizza()
                                {
                                    Order = Order,
                                    Pizza = Pizza,
                                    Price = Pizza.Price,
                                };
                                context.Add(OrderPizza);
                                OrderTotalPrice += Pizza.Price;
                            }
                        }
                        //custom pizza setup
                        else
                        {
                            Console.WriteLine("Pick a crust type");
                            foreach (Crust Crust in context.Crusts)
                            {
                                Console.WriteLine($"{Crust.Id}-{Crust.Type}: {Crust.Price}");
                            }
                            int CrustChoice = int.Parse(Console.ReadLine());
                            var ChosenCrust = context.Crusts.SingleOrDefault(a => a.Id == CrustChoice);

                            Console.WriteLine("Pick a size type");
                            foreach (Size Size in context.Sizes)
                            {
                                Console.WriteLine($"{Size.Id}-{Size.Type}: {Size.Price}");
                            }
                            int SizeChoice = int.Parse(Console.ReadLine());
                            var ChosenSize = context.Sizes.SingleOrDefault(a => a.Id == SizeChoice);

                            //Has to be modified to allow picking an array of toppings
                            decimal        PizzaPrice     = 0;
                            List <Topping> ChosenToppings = new List <Topping>();
                            ChosenToppings.Add(context.Toppings.Single(a => a.Id == 1));
                            ChosenToppings.Add(context.Toppings.Single(a => a.Id == 2));
                            PizzaPrice += 4;
                            for (int i = 0; i < 3; i++)
                            {
                                Console.WriteLine("Pick a Topping type, -1 to exit");
                                foreach (Topping Topping in context.Toppings)
                                {
                                    Console.WriteLine($"{Topping.Id}-{Topping.Type}: {Topping.Price}");
                                }
                                int ToppingChoice = int.Parse(Console.ReadLine());
                                if (ToppingChoice != -1)
                                {
                                    var ChosenTopping = context.Toppings.Single(a => a.Id == ToppingChoice);
                                    ChosenToppings.Add(ChosenTopping);
                                    PizzaPrice += ChosenTopping.Price;
                                }
                                else
                                {
                                    i = 24;
                                }
                            }
                            PizzaPrice += ChosenCrust.Price;
                            PizzaPrice += ChosenSize.Price;

                            //var Pizza = context.Pizzas.SingleOrDefault(a => a.Crust == ChosenCrust && a.Size == ChosenSize && a.PizzaToppings == { ChosenTopping} );
                            if (OrderTotalPrice + PizzaPrice > PriceLimit)
                            {
                                OrderOrNot = 0;
                                Console.WriteLine("You've exceed the order price limit, discarding the last selected pizza");
                            }
                            else
                            {
                                var OrderPizza = new OrderPizza()
                                {
                                    Order = Order,
                                    Price = PizzaPrice,
                                };
                                context.Add(OrderPizza);
                                OrderTotalPrice += PizzaPrice;
                            }
                        }
                        if (OrderOrNot == 1)
                        {
                            Console.WriteLine("Enter 1 to keep ordering, 0 if you want to finalize your order");
                            OrderOrNot = int.Parse(Console.ReadLine());
                        }
                    }
                }
                Order.Price = OrderTotalPrice;
                context.Add(Order);
                context.SaveChanges();
                //At this point we have the order and the OrderPizzas in the database,
                //Price is below 250 and # items is < 50
                //let user remove items if they choose

                Console.WriteLine("Enter 1 to modify your order, or 0 to see final price");
                int ModifyChoice = int.Parse(Console.ReadLine());
                while (ModifyChoice == 1)
                {
                    var Items = context.OrderPizzas
                                .Where(a => a.OrderId == Order.Id)
                                .ToList();
                    if (Items.Count > 0)
                    {
                        Console.WriteLine("Enter number corresponding to the order item you want removed");
                        foreach (var Item in Items)
                        {
                            Console.WriteLine($"{Item.Id}: Pizza that costs {Item.Price} dollars");
                        }
                        int ItemSelection = int.Parse(Console.ReadLine());
                        var ItemToRemove  = context.OrderPizzas.Single(a => a.OrderId == Order.Id && a.Id == ItemSelection);
                        context.OrderPizzas.Remove(ItemToRemove);
                        Order.Price -= ItemToRemove.Price;
                        context.SaveChanges();
                    }
                    else
                    {
                        Console.WriteLine("No items left to remove");
                    }
                    Console.WriteLine("Enter 1 to keep modifying your order, or 0 to see final price");
                    ModifyChoice = int.Parse(Console.ReadLine());
                }

                Console.WriteLine($"Final Price: {Order.Price}");
            }
        }
Esempio n. 19
0
        public async Task <IActionResult> Create([Bind("Id,QtySbac,QtyMbac,QtyLbac,QtySsal,QtyMsal,QtyLsal,QtySpep,QtyMpep,QtyLpep,QtySmus,QtyMmus,QtyLmus,QtySche,QtyMche,QtyLche,QtySchk,QtyMchk,QtyLchk,PriceSbac,PriceMbac,PriceLbac,PriceSsal,PriceMsal,PriceLsal,PriceSpep,PriceMpep,PriceLpep,PriceSmus,PriceMmus,PriceLmus,PriceSche,PriceMche,PriceLche,PriceSchk,PriceMchk,PriceLchk,pizzaTypeBac,pizzaTypeSal,pizzaTypePep,pizzaTypeMus,pizzaTypeChe,pizzaTypeChk,customerId,customerEmail,orderId,OrderDate,totalPrice")] OrderPizza orderPizza)
        {
            orderPizza.pizzaTypeBac = "Bacon";
            orderPizza.pizzaTypePep = "Pepperoni";
            orderPizza.pizzaTypeSal = "Salami";
            orderPizza.pizzaTypeChe = "Cheese";
            orderPizza.pizzaTypeChk = "Chicken";
            orderPizza.pizzaTypeMus = "Mushroom";

            var CustId = await _context.Customers.ToListAsync();

            int currCustId;

            if (CustId.Count != 0)
            {
                currCustId = CustId.Max(c => c.Id);
            }
            else
            {
                currCustId = 1;
            }
            orderPizza.customerId = currCustId;

            var OrderId = await _context.Orders.ToListAsync();

            int currOrderId;

            if (OrderId.Count != 0)
            {
                currOrderId = OrderId.Max(o => o.Id) + 1;
            }
            else
            {
                currOrderId = 1;
            }
            if (ModelState.IsValid)
            {
                Order order = new Order()
                {
                    totalPrice = orderPizza.totalPrice,
                    OrderDate  = orderPizza.OrderDate,
                    CustomerId = currCustId,
                    //Id = currCustId
                };
                _context.Add(order);
                //await _context.SaveChangesAsync();
                if (orderPizza.QtySbac != 0 || orderPizza.QtyMbac != 0 || orderPizza.QtyLbac != 0)
                {
                    Pizza bacPizza = new Pizza()
                    {
                        PizzaType = orderPizza.pizzaTypeBac,
                        QtyS      = orderPizza.QtySbac,
                        QtyM      = orderPizza.QtyMbac,
                        QtyL      = orderPizza.QtyLbac,
                        OrderId   = currOrderId
                    };
                    _context.Add(bacPizza);
                    //await _context.SaveChangesAsync();
                }
                if (orderPizza.QtySsal != 0 || orderPizza.QtyMsal != 0 || orderPizza.QtyLsal != 0)
                {
                    Pizza salPizza = new Pizza()
                    {
                        PizzaType = orderPizza.pizzaTypeSal,
                        QtyS      = orderPizza.QtySsal,
                        QtyM      = orderPizza.QtyMsal,
                        QtyL      = orderPizza.QtyLsal,
                        OrderId   = currOrderId
                    };
                    _context.Add(salPizza);
                    //await _context.SaveChangesAsync();
                }
                if (orderPizza.QtySpep != 0 || orderPizza.QtyMpep != 0 || orderPizza.QtyLpep != 0)
                {
                    Pizza pepPizza = new Pizza()
                    {
                        PizzaType = orderPizza.pizzaTypePep,
                        QtyS      = orderPizza.QtySpep,
                        QtyM      = orderPizza.QtyMpep,
                        QtyL      = orderPizza.QtyLpep,
                        OrderId   = currOrderId
                    };
                    _context.Add(pepPizza);
                    //await _context.SaveChangesAsync();
                }
                if (orderPizza.QtySmus != 0 || orderPizza.QtyMmus != 0 || orderPizza.QtyLmus != 0)
                {
                    Pizza musPizza = new Pizza()
                    {
                        PizzaType = orderPizza.pizzaTypeMus,
                        QtyS      = orderPizza.QtySmus,
                        QtyM      = orderPizza.QtyMmus,
                        QtyL      = orderPizza.QtyLmus,
                        OrderId   = currOrderId
                    };
                    _context.Add(musPizza);
                    //await _context.SaveChangesAsync();
                }
                if (orderPizza.QtySche != 0 || orderPizza.QtyMche != 0 || orderPizza.QtyLche != 0)
                {
                    Pizza chePizza = new Pizza()
                    {
                        PizzaType = orderPizza.pizzaTypeChe,
                        QtyS      = orderPizza.QtySche,
                        QtyM      = orderPizza.QtyMche,
                        QtyL      = orderPizza.QtyLche,
                        OrderId   = currOrderId
                    };
                    _context.Add(chePizza);
                    //await _context.SaveChangesAsync();
                }
                if (orderPizza.QtySchk != 0 || orderPizza.QtyMchk != 0 || orderPizza.QtyLchk != 0)
                {
                    Pizza chkPizza = new Pizza()
                    {
                        PizzaType = orderPizza.pizzaTypeBac,
                        QtyS      = orderPizza.QtySchk,
                        QtyM      = orderPizza.QtyMchk,
                        QtyL      = orderPizza.QtyLchk,
                        OrderId   = currOrderId
                    };
                    _context.Add(chkPizza);
                    //await _context.SaveChangesAsync();
                }

                await _context.SaveChangesAsync();

                return(RedirectToAction("Index", "Orders"));
            }
            return(View("Views/Home/Index.cshtml"));
        }
 public OrderViewModel(Order orderOpen)
 {
     orderView  = orderOpen;
     OrderPizza = new OrderPizza();
 }
 public void Edit(OrderPizza orderPizza)
 {
     //updates the current orderPizza
     _db.Update(orderPizza);
 }
Esempio n. 22
0
 public void Add([FromBody] OrderPizza item)
 {
     _repository.Add(item);
 }
Esempio n. 23
0
        private async Task <DialogTurnResult> StartOrderingPizzaAsync(WaterfallStepContext stepContext, OrderPizza result, CancellationToken cancellationToken)
        {
            var orderInfo = new OrderInfo();
            await _orderInfo.SetAsync(stepContext.Context, orderInfo, cancellationToken);

            var    entities  = result.Entities;
            double?number    = entities.number?.FirstOrDefault();
            var    orderType = entities.OrderType?.FirstOrDefault()?.FirstOrDefault();

            orderInfo.OrderType = orderType switch
            {
                "Delivery" => OrderType.Delivery,
                "PickUp" => OrderType.PickUp,
                _ => OrderType.Undefined
            };

            if (number.HasValue)
            {
                orderInfo.NumberOfPizzas = Convert.ToInt32(number.Value);
            }
            return(await stepContext.BeginDialogAsync(nameof(OrderPizzaDialog), null, cancellationToken));
        }
    }
Esempio n. 24
0
        private static void Sample3()
        {
            IPizza pizza = OrderPizza.Order("Vegetarian", "Large");

            OrderPizza.ReviewOrder(pizza);
        }