Example #1
0
        public ActionResult Checkout(Cart cart)
        {
            if (cart.Lines.Any() == false)
            {
                ModelState.AddModelError("Cart", "Désolé, votre panier est vide.");
            }

            if (ModelState.IsValid)
            {
                double totalTimeToCook = cart.Lines.Sum(x => x.Dish.TimeToCook);
                int amount = (int) cart.Lines.Sum(x => x.Dish.Price);

                int tableId = GetTableId();

                Table table = restaurantService.GetTable(tableId);

                Order order = new Order()
                {
                    Table = table,
                    OrderState = OrderState.New,
                    CartLines = cart.Lines,
                    Price = cart.Lines.Sum(x => x.Dish.TimeToCook),
                    Date = DateTime.Now
                };

                OrderService orderService = new OrderService();
                orderService.AddOrder(order);

                this.HttpContext.Session.Clear();

                return View("Paypal", amount);

                //return View(totalTimeToCook);
            }
            return RedirectToAction("Index", "Client");
        }
Example #2
0
 public WaiterController()
 {
     orderService = new OrderService();
 }
Example #3
0
 public KitchenController()
 {
     orderService = new OrderService();
 }
Example #4
0
        public ActionResult ListOrders()
        {
            OrderService orderService = new OrderService();
            List<Order> orders = orderService.GetAllOrders();

            return View(orders);
        }