本文整理汇总了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);
}
示例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());
}
示例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);
}
示例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);
}
}
示例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);
}
示例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);
}
}
示例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);
}
}
示例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);
}
}
示例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);
}
}
示例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);
}
示例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);
}
示例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);
}
示例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());
}
示例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);
}
}
示例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);
}