本文整理匯總了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() });
}