예제 #1
0
        public void DeleteCart_True()
        {
            var cartVM = new CartViewModel();

            cartVM.PurchasedProducts.Add(product);
            cartVM.ClearCart();
            Assert.AreEqual(0, cartVM.PurchasedProducts.Count);
        }
예제 #2
0
        public ActionResult Checkout(OrderForm orderForm)
        {
            var cart = db.Cart.Where(x => x.UserName == orderForm.UserName).ToList();

            if (cart == null)
            {
                ModelState.AddModelError("", "Sepetinizde ürün bulunmamaktadır.");
            }

            if (ModelState.IsValid)
            {
                OrderViewModel.SaveOrder(cart, orderForm);
                CartViewModel.ClearCart(orderForm.UserName);

                return(View("Completed"));
            }
            else
            {
                return(View(orderForm));
            }
        }
예제 #3
0
        public ActionResult Clear()
        {
            CartViewModel.ClearCart(User.Identity.Name);

            return(RedirectToAction("Index"));
        }