示例#1
0
        public IActionResult Order(OrderViewModel model)
        {
            Order             order  = new Order();
            List <PizzaOrder> pizzas = new List <PizzaOrder>();

            foreach (PizzaViewModel pizzaViewModel in model.Pizzas)
            {
                PizzaOrder pizzaOrder = new PizzaOrder()
                {
                    Pizza = _pizzaOrderService.GetPizzaFromMenu(pizzaViewModel.Name, pizzaViewModel.Size),
                    Order = order
                };
                pizzaOrder.PizzaId = pizzaOrder.Pizza.Id;
                pizzas.Add(pizzaOrder);
            }
            User user = new User()
            {
                Address   = model.Address,
                FirstName = model.FirstName,
                LastName  = model.LastName,
                Phone     = model.Phone
            };

            order.PizzaOrders = pizzas;
            order.User        = user;
            _pizzaOrderService.MakeNewOrder(order);
            return(View("_ThankYou"));
        }
示例#2
0
        public IActionResult Order(OrderViewModel model)
        {
            var orderId = _pizzaOrderService.MakeNewOrder(model);

            if (orderId != 0)
            {
                return(View("_ThankYou"));
            }

            return(RedirectToAction("Order", model));
        }
        public IActionResult Order(OrderViewModel model)
        {
            // TODO: Make validation
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            var orderId = _pizzaOrderService.MakeNewOrder(model);

            if (orderId != 0)
            {
                return(View("_ThankYou"));
            }

            return(RedirectToAction("Order", model));
        }
示例#4
0
        public IActionResult Order(OrderViewModel model)
        {
            List <Pizza> pizzas = new List <Pizza>();

            foreach (PizzaViewModel pizzaViewModel in model.Pizzas)
            {
                pizzas.Add(_pizzaOrderService.GetPizzaFromMenu(pizzaViewModel.Name, pizzaViewModel.Size));
            }
            User user = new User()
            {
                Address   = model.Address,
                FirstName = model.FirstName,
                LastName  = model.LastName,
                Phone     = model.Phone
            };
            Order order = new Order()
            {
                Pizzas = pizzas,
                User   = user
            };

            _pizzaOrderService.MakeNewOrder(order);
            return(View("_ThankYou"));
        }