22using System . Collections . Generic ;
33using System . Linq ;
44using System . Threading . Tasks ;
5- using Microsoft . AspNetCore . Http ;
65using Microsoft . EntityFrameworkCore ;
76using Microsoft . Extensions . DependencyInjection ;
87using SimplCommerce . Infrastructure . Data ;
@@ -12,20 +11,20 @@ namespace SimplCommerce.Module.ShippingPrices.Services
1211{
1312 public class ShippingPriceService : IShippingPriceService
1413 {
15- private HttpContext _httpContext ;
14+ private readonly IServiceProvider _serviceProvider ;
1615 private readonly IRepositoryWithTypedId < ShippingProvider , string > _shippingProviderRepository ;
1716
18- public ShippingPriceService ( IHttpContextAccessor contextAccessor , IRepositoryWithTypedId < ShippingProvider , string > shippingProviderRepository )
17+ public ShippingPriceService ( IServiceProvider serviceProvider , IRepositoryWithTypedId < ShippingProvider , string > shippingProviderRepository )
1918 {
20- _httpContext = contextAccessor . HttpContext ;
19+ _serviceProvider = serviceProvider ;
2120 _shippingProviderRepository = shippingProviderRepository ;
2221 }
2322
2423 public async Task < IList < ShippingPrice > > GetApplicableShippingPrices ( GetShippingPriceRequest request )
2524 {
2625 var applicableShippingPrices = new List < ShippingPrice > ( ) ;
2726 var providers = await _shippingProviderRepository . Query ( ) . ToListAsync ( ) ;
28- var shippingRateServices = _httpContext . RequestServices . GetServices < IShippingPriceServiceProvider > ( ) ;
27+ var shippingRateServices = _serviceProvider . GetServices < IShippingPriceServiceProvider > ( ) ;
2928
3029 foreach ( var provider in providers )
3130 {
0 commit comments