示例#1
0
        public ActionResult EmptyCart(string returnUrl)
        {
            var ch = new CookieHandler();
            ch.EmptyCart();

            return RedirectToAction("Cart",new { returnUrl = returnUrl });
        }
 public void EmptyCart()
 {
     var ch = new CookieHandler();
     ch.EmptyCart();
 }
示例#3
0
        public ActionResult PlaceOrder(string returnUrl)
        {
            if (Session["LoggedIn"] != null)
            {
                if ((bool)Session["LoggedIn"])

                {
                    var productBLL = new ProductBLL();
                    var ch = new CookieHandler();

                    var productIdList = ch.GetCartProductIds();
                    var productModelList = productBLL.GetProducts(productIdList);

                    var cart = productModelList.Select(p => new CartItem()
                    {
                        ProductId = p.ProductId,
                        Name = p.ProductName,
                        Count = ch.GetCount(p.ProductId),
                        Price = p.Price
                    }).ToList();

                    var order = new OrderModel();
                    var orderlines = new List<OrderlineModel>();

                    foreach (var item in cart)
                    {
                        orderlines.Add(new OrderlineModel()
                        {
                            Count = item.Count,
                            ProductId = item.ProductId
                        });
                    }
                    order.Orderlines = orderlines;
                    order.CustomerId = new AccountBLL().GetCustomer((String)Session["Email"]).CustomerId;
                    order.Date = DateTime.Now;
                    var OrderId = _orderBLL.PlaceOrder(order);

                    if (OrderId > 0)
                    {
                        ch.EmptyCart();

                        ViewBag.LoggedIn = (bool)Session["LoggedIn"];
                        ViewBag.Reciept = GetReciept(OrderId);

                        return View("GetReciept");
                    }
                }
            }
            return RedirectToAction("Index", "Home");
        }