当前位置: 首页>>代码示例>>C#>>正文


C# Cart.RemoveLine方法代码示例

本文整理汇总了C#中SportsStore.Domain.Entities.Cart.RemoveLine方法的典型用法代码示例。如果您正苦于以下问题:C# Cart.RemoveLine方法的具体用法?C# Cart.RemoveLine怎么用?C# Cart.RemoveLine使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在SportsStore.Domain.Entities.Cart的用法示例。


在下文中一共展示了Cart.RemoveLine方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: RemoveFromCart

 public RedirectToRouteResult RemoveFromCart(Cart cart, int id, string returnUrl)
 {
     Product product = _repository.Products.FirstOrDefault(p => p.Id == id);
     if(product != null)
         cart.RemoveLine(product);
     return RedirectToAction("Index", new {returnUrl});
 }
开发者ID:MichalZawadzki,项目名称:SportsStore,代码行数:7,代码来源:CartController.cs

示例2: RemoveFromCart

 public RedirectToRouteResult RemoveFromCart(Cart cart, int productId, string returnUrl)
 {
     var product = _productRepository.All.FirstOrDefault(p => p.ProductId == productId);
     if(product != null)
         cart.RemoveLine(product);
     return RedirectToAction("Index",new {returnUrl});
 }
开发者ID:DmitryAntonov90,项目名称:SportsStore,代码行数:7,代码来源:CartController.cs

示例3: RemoveFromCart

 public RedirectToRouteResult RemoveFromCart(Cart cart,int productId, string returnUrl)
 {
     Product prod = repository.Products.FirstOrDefault(p=>p.ProductID==productId);
     if (prod!=null){
     cart.RemoveLine(prod);
     }
     return RedirectToAction("Index", new { returnUrl });
 }
开发者ID:SergioKritskiy,项目名称:SportStore,代码行数:8,代码来源:CartController.cs

示例4: RemoveFromCart

 /// <summary>
 /// 向购物车删除商品
 /// </summary>
 /// <param name="cart"></param>
 /// <param name="productId"></param>
 /// <param name="returnUrl"></param>
 /// <returns></returns>
 public RedirectToRouteResult RemoveFromCart(Cart cart, int productId, string returnUrl)
 {
     var product = _repo.Products.FirstOrDefault(a => a.ProductID == productId);
     if (product != null)
     {
         cart.RemoveLine(product);
     }
     return RedirectToAction("Index", new { returnUrl });
 }
开发者ID:BerdyPango,项目名称:Researches,代码行数:16,代码来源:CartController.cs

示例5: RemoveFromCart

        public RedirectToRouteResult RemoveFromCart(Cart cart, int productID, string returnURL)
        {
            Product product = repository.Products.FirstOrDefault(p => p.ProductID == productID);

            if (product != null)
                cart.RemoveLine(product);

            return RedirectToAction("Index", new { returnURL });
        }
开发者ID:pasena,项目名称:SportsStore,代码行数:9,代码来源:CartController.cs

示例6: AjaxRemove

        public ActionResult AjaxRemove(Cart cart, int productId)
        {
            Product product = _productRepository.Products.FirstOrDefault(p => p.ProductID == productId);

            if (product != null)
                cart.RemoveLine(product);

            return Json(new { success = true, cart });
        }
开发者ID:tenzinkabsang,项目名称:SportsStoreKnockoutified,代码行数:9,代码来源:CartController.cs

示例7: RemoveFromCart

 public RedirectToRouteResult RemoveFromCart(Cart cart, int productId)
 {
     Product product = repository.Products
     .FirstOrDefault(p => p.ProductID == productId);
     if (product != null)
     {
         cart.RemoveLine(product);
     }
     return RedirectToAction("Index", new { returnUrl = Request?.UrlReferrer?.AbsolutePath });
 }
开发者ID:GraySerg,项目名称:AspNetByAdamFreeman,代码行数:10,代码来源:CartController.cs

示例8: RemoveFromCart

        public RedirectToRouteResult RemoveFromCart(Cart cart, int productId, string returnUrl)
        {
            var line = cart.Lines.FirstOrDefault(l => l.Product.ProductID == productId);

            if (line != null)
            {
                cart.RemoveLine(line.Product);
            }

            return RedirectToAction("Index", new { returnUrl });
        }
开发者ID:roszman,项目名称:SportsStore,代码行数:11,代码来源:CartController.cs

示例9: RemoveFromCart

        public RedirectToRouteResult RemoveFromCart(Cart cart, Int32 productId, String returnUrl)
        {
            Product product = _repository.Products
                                            .FirstOrDefault(p => p.ProductID == productId);

            if (product != default(Product)) {
                cart.RemoveLine(product);
            }

            return RedirectToAction("Index", new { returnUrl });
        }
开发者ID:eugeniomiro,项目名称:SportsStore,代码行数:11,代码来源:CartController.cs

示例10: RemoveFromCart

        public RedirectToRouteResult RemoveFromCart(int? productId, string returnUrl, Cart cart)
        {
            if (productId.HasValue)
            {
                Product product = this.productRepository.Products
                    .FirstOrDefault(p => p.ProductId == productId.Value);

                if (product != null)
                {
                    cart.RemoveLine(product);
                }
            }
            return this.RedirectToAction("Index", new {returnUrl});
        }
开发者ID:moacap,项目名称:SportsStoreMVC3,代码行数:14,代码来源:CartController.cs

示例11: Can_Remove_Line

        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.Where(c => c.Product == p2).Count(), 0);
            Assert.AreEqual(target.Lines.Count(), 2);
        }
开发者ID:Meleagre,项目名称:SportsStore,代码行数:17,代码来源:CartTests.cs

示例12: Can_Remove_Line

        public void Can_Remove_Line()
        {
            Product p1 = new Product { ProductId = 1, Name = "P1" };
            Product p2 = new Product { ProductId = 2, Name = "P2" };
            Product p3 = new Product { ProductId = 3, Name = "P3" };

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

            target.RemoveLine(p2);

            Assert.AreEqual(0, target.Lines.Count(c => c.Product == p2));
            Assert.AreEqual(2, target.Lines.Count());
        }
开发者ID:erangeljr,项目名称:SportsStore,代码行数:17,代码来源:CartTests.cs

示例13: Can_Remove_Line

        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, 2);
            target.AddItem(p3, 10);
            target.AddItem(p2, 3);
            target.RemoveLine(p2);
            var results = target.Lines.ToArray();
            Assert.AreEqual(results.Length, 2);
            Assert.AreEqual(results.Count(x => x.Product == p2), 0);
        }
开发者ID:trupak,项目名称:SportsStore,代码行数:17,代码来源:CartTests.cs

示例14: Can_Remove_Line

 public void Can_Remove_Line()
 {
     // Arrange - create some test products
     Product p1 = new Product { ProductID = 1, Name = "P1" };
     Product p2 = new Product { ProductID = 2, Name = "P2" };
     Product p3 = new Product { ProductID = 3, Name = "P3" };
     // Arrange - create a new cart
     Cart target = new Cart();
     // Arrange - add some products to the cart
     target.AddItem(p1, 1);
     target.AddItem(p2, 3);
     target.AddItem(p3, 5);
     target.AddItem(p2, 1);
     // Act
     target.RemoveLine(p2);
     // Assert
     Assert.AreEqual(target.Lines.Where(c => c.Product == p2).Count(), 0);
     Assert.AreEqual(target.Lines.Count(), 2);
 }
开发者ID:dgbelkin,项目名称:SportsStore,代码行数:19,代码来源:CartTests.cs

示例15: RemoveItem

        public ActionResult RemoveItem(Cart cart, Product product)
        {
            //Product product = _productRepository.Products.FirstOrDefault(p => p.ProductID == productId);

            if (product != null)
                cart.RemoveLine(product);

            return Json(new { success = true, total = cart.ComputeTotalValue() });
        }
开发者ID:tenzinkabsang,项目名称:SportsStoreKnockoutified,代码行数:9,代码来源:CartController.cs


注:本文中的SportsStore.Domain.Entities.Cart.RemoveLine方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。