本文整理汇总了C#中System.Web.Mvc.UrlHelper.CartHref方法的典型用法代码示例。如果您正苦于以下问题:C# UrlHelper.CartHref方法的具体用法?C# UrlHelper.CartHref怎么用?C# UrlHelper.CartHref使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Web.Mvc.UrlHelper
的用法示例。
在下文中一共展示了UrlHelper.CartHref方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ShowAddToCart
public ActionResult ShowAddToCart(string productCode, int? quantity, string viewName)
{
if (productCode.IsNullOrEmpty())
{
return new EmptyResult();
}
var product = CatalogService.GetProductByCode(productCode);
if (product == null)
{
return PartialView("_unknownproduct");
}
var qty = GetQuantity(product, quantity.GetValueOrDefault(1));
var cart = AddToCart(product, qty);
// Application du tarif client
// var list = new List<Models.Product>() { product };
// CatalogService.ApplyBestPrice(list, User.GetUserPrincipal().CurrentUser);
var urlHelper = new UrlHelper(this.ControllerContext.RequestContext);
bool isCustomerPriceApplied = false;
var price = SalesService.GetProductSalePrice(product, User.GetUserPrincipal().CurrentUser, qty, out isCustomerPriceApplied);
//var cart = CartService.GetCurrentOrderCart(User.GetUserPrincipal());
ViewData.Model = new Models.CartItemNeeded()
{
Product = product,
CartUrl = urlHelper.CartHref(),
Quantity = qty,
Price = price,
Cart = cart,
};
viewName = viewName ?? "_addtocart";
return PartialView(viewName);
}
示例2: JsAddToCart
private ActionResult JsAddToCart(Models.Product product, int quantity)
{
if (product == null
|| product.SaleMode != ERPStore.Models.ProductSaleMode.Sellable)
{
return new JsonResult();
}
var cart = AddToCart(product, quantity);
var urlHelper = new UrlHelper(this.ControllerContext.RequestContext);
SalesService.ProcessExport(cart, User.GetUserPrincipal().CurrentUser);
var data = new
{
status = cart.GetStatusText(),
cartGrandTotal = cart.GrandTotal.ToString("#,#0.00"),
cartGrandTaxTotal = cart.GrandTaxTotal.ToString("#,#0.00"),
cartGrandTotalWithTax = cart.GrandTotalWithTax.ToString("#,#0.00"),
title = product.Title,
quantity = quantity,
cartUrl = urlHelper.CartHref(),
productImage = product.DefaultImage != null ? HttpUtility.UrlEncode(product.DefaultImage.Url) : string.Empty,
};
var result = Json(data);
return result;
}
示例3: JsAddItemToCart
private ActionResult JsAddItemToCart(ShoppingCart.Web.Mvc.Model.IProduct product, int quantity)
{
if (product == null)
{
return new JsonResult();
}
var price = CatalogService.GetPriceByProduct(product);
var cart = CartService.GetOrCreateCart(Request.AnonymousID);
CartService.AddItem(cart, product.Code, product.SaleUnitValue, product.Packaging, quantity, price);
var urlHelper = new UrlHelper(this.ControllerContext.RequestContext);
return Json(new
{
status = cart.GetStatusText(),
cartTotal = cart.TotalWithTax.ToString("#,#0.00"),
title = product.Title,
quantity = quantity,
cartUrl = urlHelper.CartHref(),
});
}