当前位置: 首页>>代码示例>>C#>>正文


C# UrlHelper.CartHref方法代码示例

本文整理汇总了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);
        }
开发者ID:hhariri,项目名称:ReSharper8Demo,代码行数:34,代码来源:CartController.cs

示例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;
        }
开发者ID:hhariri,项目名称:ReSharper8Demo,代码行数:29,代码来源:CartController.cs

示例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(),
            });
        }
开发者ID:adrianrm03,项目名称:openshoppingcart,代码行数:21,代码来源:CartController.cs


注:本文中的System.Web.Mvc.UrlHelper.CartHref方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。