Skip to content

Open-source eCommerce platform for C# and ASP.NET Core 10 with MongoDB. Build multi-store shops and multi-vendor marketplaces with B2B/B2C, REST API, plugins, Vue 3 and Docker.

Changes with linkgenerator - replace GetUriByRouteValues to GetPathByRouteValues

supportc57626912755
diff --git a/src/Web/Grand.Web/Features/Handlers/Checkout/GetPaymentInfoHandler.cs b/src/Web/Grand.Web/Features/Handlers/Checkout/GetPaymentInfoHandler.cs
index be54e7034..0b556b72c 100644
--- a/src/Web/Grand.Web/Features/Handlers/Checkout/GetPaymentInfoHandler.cs
+++ b/src/Web/Grand.Web/Features/Handlers/Checkout/GetPaymentInfoHandler.cs
@@ -1,7 +1,6 @@
using Grand.Web.Features.Models.Checkout;
using Grand.Web.Models.Checkout;
using MediatR;
-using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Routing;
namespace Grand.Web.Features.Handlers.Checkout
@@ -9,17 +8,15 @@ namespace Grand.Web.Features.Handlers.Checkout
public class GetPaymentInfoHandler : IRequestHandler<GetPaymentInfo, CheckoutPaymentInfoModel>
{
private readonly LinkGenerator _linkGenerator;
- private readonly IHttpContextAccessor _httpContextAccessor;
- public GetPaymentInfoHandler(LinkGenerator linkGenerator, IHttpContextAccessor httpContextAccessor)
+ public GetPaymentInfoHandler(LinkGenerator linkGenerator)
{
_linkGenerator = linkGenerator;
- _httpContextAccessor = httpContextAccessor;
}
public async Task<CheckoutPaymentInfoModel> Handle(GetPaymentInfo request, CancellationToken cancellationToken)
{
- var url = _linkGenerator.GetUriByRouteValues(_httpContextAccessor.HttpContext, routeName: await request.PaymentMethod.GetControllerRouteName(), values: null);
+ var url = _linkGenerator.GetPathByRouteValues(routeName: await request.PaymentMethod.GetControllerRouteName(), values: null);
var model = new CheckoutPaymentInfoModel {
PaymentUrl = url
};
diff --git a/src/Web/Grand.Web/Features/Handlers/Products/GetProductOverviewHandler.cs b/src/Web/Grand.Web/Features/Handlers/Products/GetProductOverviewHandler.cs
index d8e9efa26..6cc544e0c 100644
--- a/src/Web/Grand.Web/Features/Handlers/Products/GetProductOverviewHandler.cs
+++ b/src/Web/Grand.Web/Features/Handlers/Products/GetProductOverviewHandler.cs
@@ -17,7 +17,6 @@ using Grand.Web.Features.Models.Products;
using Grand.Web.Models.Catalog;
using Grand.Web.Models.Media;
using MediatR;
-using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Routing;
using System.Diagnostics;
@@ -37,7 +36,6 @@ namespace Grand.Web.Features.Handlers.Products
private readonly IPictureService _pictureService;
private readonly IDateTimeService _dateTimeService;
private readonly IMediator _mediator;
- private readonly IHttpContextAccessor _httpContextAccessor;
private readonly LinkGenerator _linkGenerator;
private readonly MediaSettings _mediaSettings;
private readonly CatalogSettings _catalogSettings;
@@ -55,7 +53,6 @@ namespace Grand.Web.Features.Handlers.Products
IPictureService pictureService,
IDateTimeService dateTimeService,
IMediator mediator,
- IHttpContextAccessor httpContextAccessor,
LinkGenerator linkGenerator,
MediaSettings mediaSettings,
CatalogSettings catalogSettings)
@@ -72,7 +69,6 @@ namespace Grand.Web.Features.Handlers.Products
_pictureService = pictureService;
_dateTimeService = dateTimeService;
_mediator = mediator;
- _httpContextAccessor = httpContextAccessor;
_linkGenerator = linkGenerator;
_mediaSettings = mediaSettings;
_catalogSettings = catalogSettings;
@@ -170,8 +166,7 @@ namespace Grand.Web.Features.Handlers.Products
ShortDescription = product.GetTranslation(x => x.ShortDescription, _workContext.WorkingLanguage.Id),
FullDescription = product.GetTranslation(x => x.FullDescription, _workContext.WorkingLanguage.Id),
SeName = sename,
- Url = _linkGenerator.GetUriByRouteValues(_httpContextAccessor.HttpContext, "Product",
- new { SeName = sename }),
+ Url = _linkGenerator.GetPathByRouteValues("Product", new { SeName = sename }),
ProductType = product.ProductTypeId,
Sku = product.Sku,
Gtin = product.Gtin,
diff --git a/src/Web/Grand.Web/Features/Handlers/ShoppingCart/GetMiniShoppingCartHandler.cs b/src/Web/Grand.Web/Features/Handlers/ShoppingCart/GetMiniShoppingCartHandler.cs
index a6111f1ba..16d9dc61c 100644
--- a/src/Web/Grand.Web/Features/Handlers/ShoppingCart/GetMiniShoppingCartHandler.cs
+++ b/src/Web/Grand.Web/Features/Handlers/ShoppingCart/GetMiniShoppingCartHandler.cs
@@ -18,7 +18,6 @@ using Grand.Web.Features.Models.ShoppingCart;
using Grand.Web.Models.Media;
using Grand.Web.Models.ShoppingCart;
using MediatR;
-using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Routing;
namespace Grand.Web.Features.Handlers.ShoppingCart
@@ -37,7 +36,6 @@ namespace Grand.Web.Features.Handlers.ShoppingCart
private readonly IPictureService _pictureService;
private readonly IGroupService _groupService;
private readonly IMediator _mediator;
- private readonly IHttpContextAccessor _httpContextAccessor;
private readonly LinkGenerator _linkGenerator;
private readonly ShoppingCartSettings _shoppingCartSettings;
private readonly OrderSettings _orderSettings;
@@ -57,7 +55,6 @@ namespace Grand.Web.Features.Handlers.ShoppingCart
IGroupService groupService,
IPictureService pictureService,
IMediator mediator,
- IHttpContextAccessor httpContextAccessor,
LinkGenerator linkGenerator,
ShoppingCartSettings shoppingCartSettings,
OrderSettings orderSettings,
@@ -76,7 +73,6 @@ namespace Grand.Web.Features.Handlers.ShoppingCart
_groupService = groupService;
_pictureService = pictureService;
_mediator = mediator;
- _httpContextAccessor = httpContextAccessor;
_linkGenerator = linkGenerator;
_shoppingCartSettings = shoppingCartSettings;
_orderSettings = orderSettings;
@@ -146,8 +142,7 @@ namespace Grand.Web.Features.Handlers.ShoppingCart
ProductId = product.Id,
ProductName = product.GetTranslation(x => x.Name, request.Language.Id),
ProductSeName = sename,
- ProductUrl = _linkGenerator.GetUriByRouteValues(_httpContextAccessor.HttpContext, "Product",
- new { SeName = sename }),
+ ProductUrl = _linkGenerator.GetPathByRouteValues("Product", new { SeName = sename }),
Quantity = sci.Quantity,
AttributeInfo = await _productAttributeFormatter.FormatAttributes(product, sci.Attributes)
};
diff --git a/src/Web/Grand.Web/Features/Handlers/ShoppingCart/GetMiniWishlistHandler.cs b/src/Web/Grand.Web/Features/Handlers/ShoppingCart/GetMiniWishlistHandler.cs
index 14e96ce57..ee9b7e912 100644
--- a/src/Web/Grand.Web/Features/Handlers/ShoppingCart/GetMiniWishlistHandler.cs
+++ b/src/Web/Grand.Web/Features/Handlers/ShoppingCart/GetMiniWishlistHandler.cs
@@ -13,7 +13,6 @@ using Grand.Web.Features.Models.ShoppingCart;
using Grand.Web.Models.Media;
using Grand.Web.Models.ShoppingCart;
using MediatR;
-using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Routing;
namespace Grand.Web.Features.Handlers.ShoppingCart
@@ -27,7 +26,6 @@ namespace Grand.Web.Features.Handlers.ShoppingCart
private readonly IPricingService _pricingService;
private readonly IPriceFormatter _priceFormatter;
private readonly IPictureService _pictureService;
- private readonly IHttpContextAccessor _httpContextAccessor;
private readonly LinkGenerator _linkGenerator;
private readonly ShoppingCartSettings _shoppingCartSettings;
private readonly MediaSettings _mediaSettings;
@@ -40,7 +38,6 @@ namespace Grand.Web.Features.Handlers.ShoppingCart
IPricingService priceCalculationService,
IPriceFormatter priceFormatter,
IPictureService pictureService,
- IHttpContextAccessor httpContextAccessor,
LinkGenerator linkGenerator,
ShoppingCartSettings shoppingCartSettings,
MediaSettings mediaSettings)
@@ -52,7 +49,6 @@ namespace Grand.Web.Features.Handlers.ShoppingCart
_pricingService = priceCalculationService;
_priceFormatter = priceFormatter;
_pictureService = pictureService;
- _httpContextAccessor = httpContextAccessor;
_linkGenerator = linkGenerator;
_shoppingCartSettings = shoppingCartSettings;
_mediaSettings = mediaSettings;
@@ -84,7 +80,7 @@ namespace Grand.Web.Features.Handlers.ShoppingCart
ProductId = product.Id,
ProductName = product.GetTranslation(x => x.Name, request.Language.Id),
ProductSeName = sename,
- ProductUrl = _linkGenerator.GetUriByRouteValues(_httpContextAccessor.HttpContext, "Product", new { SeName = sename }),
+ ProductUrl = _linkGenerator.GetPathByRouteValues("Product", new { SeName = sename }),
Quantity = sci.Quantity,
AttributeInfo = await _productAttributeFormatter.FormatAttributes(product, sci.Attributes)
};
diff --git a/src/Web/Grand.Web/Features/Handlers/ShoppingCart/GetShoppingCartHandler.cs b/src/Web/Grand.Web/Features/Handlers/ShoppingCart/GetShoppingCartHandler.cs
index da5edca63..58c699f90 100644
--- a/src/Web/Grand.Web/Features/Handlers/ShoppingCart/GetShoppingCartHandler.cs
+++ b/src/Web/Grand.Web/Features/Handlers/ShoppingCart/GetShoppingCartHandler.cs
@@ -25,7 +25,6 @@ using Grand.Web.Features.Models.ShoppingCart;
using Grand.Web.Models.Media;
using Grand.Web.Models.ShoppingCart;
using MediatR;
-using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc.Rendering;
using Microsoft.AspNetCore.Routing;
@@ -53,7 +52,6 @@ namespace Grand.Web.Features.Handlers.ShoppingCart
private readonly IGroupService _groupService;
private readonly IMediator _mediator;
private readonly IShoppingCartValidator _shoppingCartValidator;
- private readonly IHttpContextAccessor _httpContextAccessor;
private readonly LinkGenerator _linkGenerator;
private readonly MediaSettings _mediaSettings;
private readonly OrderSettings _orderSettings;
@@ -82,7 +80,6 @@ namespace Grand.Web.Features.Handlers.ShoppingCart
IGroupService groupService,
IMediator mediator,
IShoppingCartValidator shoppingCartValidator,
- IHttpContextAccessor httpContextAccessor,
LinkGenerator linkGenerator,
MediaSettings mediaSettings,
OrderSettings orderSettings,
@@ -110,7 +107,6 @@ namespace Grand.Web.Features.Handlers.ShoppingCart
_groupService = groupService;
_mediator = mediator;
_shoppingCartValidator = shoppingCartValidator;
- _httpContextAccessor = httpContextAccessor;
_linkGenerator = linkGenerator;
_mediaSettings = mediaSettings;
_orderSettings = orderSettings;
@@ -319,7 +315,7 @@ namespace Grand.Web.Features.Handlers.ShoppingCart
WarehouseId = sci.WarehouseId,
ProductName = product.GetTranslation(x => x.Name, request.Language.Id),
ProductSeName = sename,
- ProductUrl = _linkGenerator.GetUriByRouteValues(_httpContextAccessor.HttpContext, "Product", new { SeName = sename }),
+ ProductUrl = _linkGenerator.GetPathByRouteValues("Product", new { SeName = sename }),
Quantity = sci.Quantity,
AttributeInfo = await _productAttributeFormatter.FormatAttributes(product, sci.Attributes),
AllowItemEditing = _shoppingCartSettings.AllowCartItemEditing && product.VisibleIndividually
diff --git a/src/Web/Grand.Web/Features/Handlers/ShoppingCart/GetWishlistHandler.cs b/src/Web/Grand.Web/Features/Handlers/ShoppingCart/GetWishlistHandler.cs
index 1dbf81b01..00254eadd 100644
--- a/src/Web/Grand.Web/Features/Handlers/ShoppingCart/GetWishlistHandler.cs
+++ b/src/Web/Grand.Web/Features/Handlers/ShoppingCart/GetWishlistHandler.cs
@@ -18,7 +18,6 @@ using Grand.Web.Features.Models.ShoppingCart;
using Grand.Web.Models.Media;
using Grand.Web.Models.ShoppingCart;
using MediatR;
-using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc.Rendering;
using Microsoft.AspNetCore.Routing;
@@ -35,7 +34,6 @@ namespace Grand.Web.Features.Handlers.ShoppingCart
private readonly IPriceFormatter _priceFormatter;
private readonly IPictureService _pictureService;
private readonly IShoppingCartValidator _shoppingCartValidator;
- private readonly IHttpContextAccessor _httpContextAccessor;
private readonly LinkGenerator _linkGenerator;
private readonly ShoppingCartSettings _shoppingCartSettings;
private readonly CatalogSettings _catalogSettings;
@@ -51,7 +49,6 @@ namespace Grand.Web.Features.Handlers.ShoppingCart
IPriceFormatter priceFormatter,
IPictureService pictureService,
IShoppingCartValidator shoppingCartValidator,
- IHttpContextAccessor httpContextAccessor,
LinkGenerator linkGenerator,
ShoppingCartSettings shoppingCartSettings,
CatalogSettings catalogSettings,
@@ -66,7 +63,6 @@ namespace Grand.Web.Features.Handlers.ShoppingCart
_priceFormatter = priceFormatter;
_pictureService = pictureService;
_shoppingCartValidator = shoppingCartValidator;
- _httpContextAccessor = httpContextAccessor;
_linkGenerator = linkGenerator;
_shoppingCartSettings = shoppingCartSettings;
_catalogSettings = catalogSettings;
@@ -115,7 +111,7 @@ namespace Grand.Web.Features.Handlers.ShoppingCart
ProductId = product.Id,
ProductName = product.GetTranslation(x => x.Name, request.Language.Id),
ProductSeName = sename,
- ProductUrl = _linkGenerator.GetUriByRouteValues(_httpContextAccessor.HttpContext, "Product", new { SeName = sename }),
+ ProductUrl = _linkGenerator.GetPathByRouteValues("Product", new { SeName = sename }),
Quantity = sci.Quantity,
AttributeInfo = await _productAttributeFormatter.FormatAttributes(product, sci.Attributes),
AllowItemEditing = _shoppingCartSettings.AllowCartItemEditing && product.VisibleIndividually