예제 #1
0
 public RedirectToRouteResult RemoveFromCart(Cart cart, int productId, string returnUrl)
 {
     var product = repository.Products.FirstOrDefault(p => p.ProductID == productId);
     if (product != null)
     {
         cart.RemoveLine(product);
     }
     return RedirectToAction("Index", new { returnUrl });
 }
예제 #2
0
 public RedirectToRouteResult RemoveFromCart(Cart cart, int productId, string returnUrl)
 {
     Product product = prodRepo.GetProductDetails(productId);
     if (product != null)
     {
         //GetCart().RemoveLine(product);
         cart.RemoveLine(product);
     }
     return RedirectToAction("Index", new { returnUrl });
 }
예제 #3
0
        public RedirectToRouteResult RemoveFromCart(Cart cart, long id, string returnUrl)
        {
            Furniture furniture = repository.Furnitures
                .FirstOrDefault(f => f.Id == id);

            if (furniture != null)
            {
                cart.RemoveLine(furniture);
            }
            return RedirectToAction("Index", new { returnUrl });
        }
예제 #4
0
        public void Can_Remove_Line()
        {
            var p1 = new Product { ProductID = 1, Name = "P1" };
            var p2 = new Product { ProductID = 2, Name = "P2" };
            var p3 = new Product { ProductID = 3, Name = "P3" };
            var target = new Cart();
            target.AddItem(p1, 1);
            target.AddItem(p2, 3);
            target.AddItem(p3, 5);
            target.AddItem(p2, 1);

            target.RemoveLine(p2);

            Assert.AreEqual(target.Lines.Count(c => c.Product == p2), 0);
            Assert.AreEqual(target.Lines.Count(), 2);
        }
예제 #5
0
        public void Can_Remove_Lines()
        {
            // Arrange
            var p1 = new Product { ProductId = 1, Name = "P1" };
            var p2 = new Product { ProductId = 2, Name = "P2" };
            var p3 = new Product { ProductId = 3, Name = "P3" };

            var target = new Cart();

            // Act

            target.AddItem(p1, 1);
            target.AddItem(p2, 3);
            target.AddItem(p3, 5);
            target.AddItem(p2, 1);

            target.RemoveLine(p2);

            Assert.AreEqual(target.Lines.Count(), 2);
            Assert.AreEqual(target.Lines.Count(p => p.Product == p2), 0);
        }