Ejemplo n.º 1
0
        public ActionResult Checkout(FormCollection formData)
        {
            List<OrderItem> cartItems = (List<OrderItem>)TempData["CartItems"];

            TempData["CartItems"] = cartItems;

            Order order = new Order();
            order.OrderItems = cartItems;

            ProcessOrder(order);

            string action = formData["goto"];
            if (action == "Shop More!")
            {
                return RedirectToAction("Index");
            }
            else if (action == "Enter Delivery Information")
            {
                return RedirectToAction("Order");
            }
            else
            {
                return View(order);
            }
        }
Ejemplo n.º 2
0
        public ActionResult Checkout()
        {
            List<OrderItem> cartItems = (List<OrderItem>)TempData["CartItems"];

            TempData["CartItems"] = cartItems;

             Order order = new Order();
            order.OrderItems = cartItems;

            ProcessOrder(order);

            return View(order);
        }
Ejemplo n.º 3
0
        public void ProcessOrder(Order order)
        {
            //applying some business logic :)
            order.TotalAmount = order.OrderItems.Sum(x => x.Price * x.Qty);

            if (order.TotalAmount > 500)
            {
                //give a disocunt of 5% if total is greater than 500
                order.Discount = order.TotalAmount * 0.05m;
            }
            else
            {
                if (order.OrderItems.Count > 4)
                {
                    //give a discount of 1% if there are more than 4 items in an order
                    order.Discount = order.TotalAmount * 0.01m;
                }
            }

            order.PayableAmount = order.TotalAmount - order.Discount;
        }