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