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


C# Cart.Clear方法代碼示例

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


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

示例1: CheckOut

        public ActionResult 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 // Something was invalid
                return View(shippingDetails);
        }
開發者ID:sbetchel,項目名稱:SportsStore,代碼行數:14,代碼來源:CartController.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");
     }
     else
     {
         return View(shippingDetails);
     }
 }
開發者ID:HowardHaoSun,項目名稱:GITProject1,代碼行數:17,代碼來源:CartController.cs

示例3: CheckOut

 public ActionResult CheckOut(Cart cart, /*ShippingDetails spDetails*/ FormCollection form)
 {
     if (cart.Lines.Count == 0)
     {
         ModelState.AddModelError("Cart", "Ваша корзина пуста");
         return View();
     }
     if (TryUpdateModel(cart.ShippingDetails, form.ToValueProvider()))
     {
         _orderSubmitter.SumbitterOrder(cart);
         cart.Clear();
         return View("Comleted");
     }
     else
     {
         return View();
     }
     //if (!ModelState.IsValid)
     //    RedirectToAction("CheckOut");
     //_dataManager.Order.CreateOrder(cart, spDetails);
     //return View("Comleted");
 }
開發者ID:xs2ranjeet,項目名稱:13ns9-1spr,代碼行數:22,代碼來源:CartController.cs

示例4: paymentTaken

        public ActionResult paymentTaken()
        {
            cart = getCart();

            if (cart == null || cart.Lines.Count == 0)
                return View();

            cart.Clear();
            return View();
        }
開發者ID:n-alex-white,項目名稱:MallowAndWhite,代碼行數:10,代碼來源:CartController.cs

示例5: CartCanBeCleared

        public void CartCanBeCleared()
        {
            Cart cart = new Cart();
            cart.AddItem(new Product(), 1);

            cart.Clear();
            cart.Lines.Count.ShouldEqual(0);
        }
開發者ID:sbetchel,項目名稱:SportsStore,代碼行數:8,代碼來源:ShoppingCart.cs

示例6: Can_Clear_Contents

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

            var target = new Cart();

            // Act

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

            target.Clear();

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


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