當前位置: 首頁>>代碼示例>>C#>>正文


C# Cart.Clear方法代碼示例

本文整理匯總了C#中SportsStore.Domain.Entities.Cart.Clear方法的典型用法代碼示例。如果您正苦於以下問題:C# Cart.Clear方法的具體用法?C# Cart.Clear怎麽用?C# Cart.Clear使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在SportsStore.Domain.Entities.Cart的用法示例。


在下文中一共展示了Cart.Clear方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: Delete_All_Lines_From_Cart

        public void Delete_All_Lines_From_Cart()
        {
            Cart target = new Cart(); // TODO: Initialize to an appropriate value

            target.AddItem(products[0], 5);
            target.AddItem(products[1], 2);
            target.AddItem(products[2], 3);

            target.Clear();

            Assert.IsTrue( target.Lines.Count() == 0);
        }
開發者ID:najamsk,項目名稱:SportsStore,代碼行數:12,代碼來源:CartTest.cs

示例2: Checkout

 public ViewResult Checkout(Cart cart, ShippingDetails shippingDetails)
 {
     if(cart.Lines.Count()==0){
         ModelState.AddModelError("", "Sorry, your cart is empty!");
     }
     if(ModelState.IsValid){
         orderProcessor.ProcessOrder(cart, shippingDetails);
         cart.Clear();
         return View("Completed");
     }
     return View(new ShippingDetails());
 }
開發者ID:SergioKritskiy,項目名稱:SportStore,代碼行數:12,代碼來源:CartController.cs

示例3: Can_Clear_Contents

        public void Can_Clear_Contents()
        {
            Product p1 = new Product { ProductID = 1, Name = "P1", Price = 100M };
            Product p2 = new Product { ProductID = 2, Name = "P2", Price = 50M };

            Cart target = new Cart();

            target.AddItem(p1, 1);
            target.AddItem(p2, 1);

            target.Clear();

            Assert.AreEqual(target.Lines.Count(), 0);
        }
開發者ID:akuczynski,項目名稱:SportsStore,代碼行數:14,代碼來源:CartTest.cs

示例4: Checkout

 public ViewResult Checkout(Cart cart, ShippingDetails shippingDetails)
 {
     if(cart.Lines.Count() == 0)
         ModelState.AddModelError("", "Koszyk jest pusty");
     if (ModelState.IsValid)
     {
         _orderProcessor.ProcessOrder(cart, shippingDetails);
         cart.Clear();
         return View("Completed");
     }
     else
     {
         return View(shippingDetails);
     }
 }
開發者ID:MichalZawadzki,項目名稱:SportsStore,代碼行數:15,代碼來源:CartController.cs

示例5: Can_Clear_Contents

 public void Can_Clear_Contents()
 {
     // Arrange - create some test products
     Product p1 = new Product { ProductID = 1, Name = "P1", Price = 100M };
     Product p2 = new Product { ProductID = 2, Name = "P2", Price = 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);
 }
開發者ID:gustavarrhenius,項目名稱:Lab3,代碼行數:15,代碼來源:CanClearContentsTest.cs

示例6: Checkout

        public ViewResult Checkout(Cart cart, ShippingDetails shippingDetails)
        {
            if (!cart.Lines.Any())
                ModelState.AddModelError("", "Sorry, your cart is empty");

            if (ModelState.IsValid)
            {
                orderProcessor.ProcessOrder(cart, shippingDetails);
                cart.Clear();
                return View("Completed");
            }
            else
            {
                return View(shippingDetails);
            }
        }
開發者ID:nholik,項目名稱:SportsStore,代碼行數:16,代碼來源:CartController.cs

示例7: CheckOut

        public ViewResult CheckOut(Cart cart, ShippingDetails shippingDetails)
        {
            // Empty carts can't be checked out
            if (cart.Lines.Count == 0)
                ModelState.AddModelError("Cart", "Sorry, your cart is empty!");

            if (ModelState.IsValid)
            {
                orderSubmitter.SubmitOrder(cart, shippingDetails);
                cart.Clear();
                return View("Completed");
            }
            else
            {
                return View(shippingDetails);
            }
        }
開發者ID:astrateg,項目名稱:SportsStore,代碼行數:17,代碼來源:CartController.cs

示例8: Checkout

 public ViewResult Checkout(Cart cart, ShippingDetails shippingDetails)
 {
     if (cart.Lines.Count() == 0)
     {
         ModelState.AddModelError("", "Sorry, your cart is empty!");
     }
     //isValid will check to see if our data annotations have thrown an error
     if (ModelState.IsValid)
     {
         orderProcessor.ProcessOrder(cart, shippingDetails);
         cart.Clear();
         return View("Completed");
     }
     else
     {
         return View(shippingDetails);
     }
 }
開發者ID:rich-staackmann,項目名稱:SportsStore,代碼行數:18,代碼來源:CartController.cs

示例9: Checkout

 public ViewResult Checkout(Cart cart, OrderHeader orderHeader, ShippingDetails shippingDetails)
 {
     if (cart.Lines.Count() == 0)
     {
         ModelState.AddModelError("", "Sorry, your cart is empty!");
     }
     if (ModelState.IsValid)
     {
         orderProcessor.ProcessOrder(cart, orderHeader,
                                     User.Identity.GetUserId().ToString(),
                                     User.Identity.GetUserName());
         cart.Clear();
         return View("Completed");
     }
     else
     {
         return View(shippingDetails);
     }
 }
開發者ID:switch527,項目名稱:SportsStore,代碼行數:19,代碼來源:CartController.cs

示例10: Cart_Can_Be_Cleared

 public void Cart_Can_Be_Cleared()
 {
     var cart = new Cart();
     cart.AddItem(new Product(), 1);
     cart.Clear();
     cart.Lines.Count.ShouldEqual(0);
 }
開發者ID:hcabnettek,項目名稱:SportsStore,代碼行數:7,代碼來源:ShoppingCart.cs

示例11: Clear_AllItem_Removed

 public void Clear_AllItem_Removed()
 {
     Product p1 = new Product { ProductName = "P1", ProductID = 1 };
     Product p2 = new Product { ProductName = "P2", ProductID = 2 };
     Cart cart = new Cart();
     cart.AddItem(p1, 2);
     cart.AddItem(p2, 1);
     cart.Clear();
     CartLine[] lineCollection = cart.Lines.ToArray();
     Assert.IsTrue(lineCollection.Length == 0);
 }
開發者ID:vinhchung,項目名稱:SportsStore,代碼行數:11,代碼來源:CartTest.cs

示例12: Can_Cleaer

        public void Can_Cleaer()
        {
            Product p1 = new Product { ProductID = 1, Name = "p1", Price = 500M };
            Product p2 = new Product { ProductID = 2, Name = "p2", Price = 150M };

            Cart target = new Cart();

            target.AddItem(p1, 1);
            target.AddItem(p2, 2);
            target.AddItem(p1, 4);

            target.Clear();

            Assert.AreEqual(target.Lines.Count(), 0);
        }
開發者ID:rialhstu,項目名稱:Online-Shopping,代碼行數:15,代碼來源:UnitTest1.cs

示例13: CanClearContents

        public void CanClearContents()
        {
            //array
            var prod1 = new Product { ProductID = 1, Name = "p1", Price = 100M };
            var prod2 = new Product { ProductID = 2, Name = "p2", Price = 50M };

            //arrange
            var target = new Cart();
            target.AddProduct(prod1, 2);
            target.AddProduct(prod1, 8);
            target.AddProduct(prod2, 1);

            //act
            target.Clear();

            //assert
            Assert.AreEqual(0, target.Lines.Count());
        }
開發者ID:Itdotaer,項目名稱:SportsStore,代碼行數:18,代碼來源:Products.cs

示例14: Checkout2

 public ViewResult Checkout2(Cart cart, OrderHeader orderHeader)
 {
     if (cart.Lines.Count() == 0)
     {
         ModelState.AddModelError("", "Sorry, your cart is empty!");
     }
     if (ModelState.IsValid)
     {
         //The following orderProcessor.ProcessOrder method might be underlined in red.
         //This will be fixed later when you update the EmailOrderProcessor.cs file and NinjectControllerFactory.cs (see Steps 9 and 10)
         orderProcessor.ProcessOrder(cart, orderHeader,
                                     User.Identity.GetUserId().ToString(),
                                     User.Identity.GetUserName());
         cart.Clear();
         return View("Completed");
     }
     else
     {
         return View(orderHeader);
     }
 }
開發者ID:switch527,項目名稱:SportsStore,代碼行數:21,代碼來源:CartController.cs

示例15: Can_Clear_Contents

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

            var target = new Cart();

            target.AddItem(p1, 1);
            target.AddItem(p2, 2);
            target.AddItem(p3, 10);
            target.AddItem(p2, 3);
            target.Clear();
            Assert.AreEqual(target.Lines.Count(), 0);
        }
開發者ID:trupak,項目名稱:SportsStore,代碼行數:15,代碼來源:CartTests.cs


注:本文中的SportsStore.Domain.Entities.Cart.Clear方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。