本文整理匯總了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);
}
示例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);
}
}
示例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");
}
示例4: paymentTaken
public ActionResult paymentTaken()
{
cart = getCart();
if (cart == null || cart.Lines.Count == 0)
return View();
cart.Clear();
return View();
}
示例5: CartCanBeCleared
public void CartCanBeCleared()
{
Cart cart = new Cart();
cart.AddItem(new Product(), 1);
cart.Clear();
cart.Lines.Count.ShouldEqual(0);
}
示例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);
}