Пример #1
0
 public RedirectToRouteResult ClearCart(CART cart, string returnUrl)
 {
     if (cart.Lines.Count() > 0)
     {
         cart.Clear();
     }
     return(RedirectToAction("List", "Product"));
 }
Пример #2
0
 public ViewResult Checkout(CART cart, SHIPPING_DETAILS shippingDetails)
 {
     if (cart.Lines.Count() == 0)
     {
         ModelState.AddModelError("", "Извините, ваша корзина пуста!");
     }
     if (ModelState.IsValid)
     {
         orderProcessor.ProcessOrder(cart, shippingDetails);
         orderProcessor.SaveOrder(cart, shippingDetails);
         ViewBag.NameApp = this.repository.NameApp();
         cart.Clear();
         return(View("Completed"));
     }
     else
     {
         return(View(shippingDetails));
     }
 }
Пример #3
0
        public void Can_Clear_Contents()
        {
            // Arrange - create some test products
            PRODUCT p1 = new PRODUCT {
                ProductId = 1, Name = "P1", PriceWithVat = 100M
            };
            PRODUCT p2 = new PRODUCT {
                ProductId = 2, Name = "P2", PriceWithVat = 50M
            };
            // Arrange - create a new cart
            CART target = new CART();

            // Arrange - add some items
            target.AddItem(p1, 1);
            target.AddItem(p2, 1);
            // Act - reset the cart
            target.Clear();
            // Assert
            Assert.AreEqual(target.Lines.Count(), 0);
        }