Skip to content

Commit

Permalink
Update platform
Browse files Browse the repository at this point in the history
  • Loading branch information
artem-dudarev committed May 16, 2024
1 parent 677ce45 commit 7d0540f
Show file tree
Hide file tree
Showing 9 changed files with 22 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<PackageReference Include="VirtoCommerce.CustomerModule.Core" Version="3.803.0" />
<PackageReference Include="VirtoCommerce.NotificationsModule.Core" Version="3.800.0" />
<PackageReference Include="VirtoCommerce.PaymentModule.Core" Version="3.800.0" />
<PackageReference Include="VirtoCommerce.Platform.Core" Version="3.800.0" />
<PackageReference Include="VirtoCommerce.Platform.Core" Version="3.825.0" />
<PackageReference Include="VirtoCommerce.ShippingModule.Core" Version="3.800.0" />
<PackageReference Include="VirtoCommerce.StoreModule.Core" Version="3.800.0" />
</ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,13 @@
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<noWarn>NU5104</noWarn>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="8.0.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Pomelo.EntityFrameworkCore.MySql" Version="8.0.0-beta.2" />
<PackageReference Include="VirtoCommerce.Platform.Data.MySql" Version="3.825.0" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\VirtoCommerce.OrdersModule.Data\VirtoCommerce.OrdersModule.Data.csproj" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Npgsql" Version="8.0.1" />
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="8.0.0" />
<PackageReference Include="VirtoCommerce.Platform.Data.PostgreSql" Version="3.825.0" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\VirtoCommerce.OrdersModule.Data\VirtoCommerce.OrdersModule.Data.csproj" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="8.0.0" />
<PackageReference Include="VirtoCommerce.Platform.Data.SqlServer" Version="3.825.0" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\VirtoCommerce.OrdersModule.Data\VirtoCommerce.OrdersModule.Data.csproj" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,15 @@ public class SendNotificationsOrderChangedEventHandler : IEventHandler<OrderChan
private readonly IStoreService _storeService;
private readonly IMemberService _memberService;
private readonly ISettingsManager _settingsManager;
private readonly UserManager<ApplicationUser> _userManager;
private readonly Func<UserManager<ApplicationUser>> _userManagerFactory;
private readonly ICustomerOrderService _orderService;

public SendNotificationsOrderChangedEventHandler(
INotificationSender notificationSender,
IStoreService storeService,
IMemberService memberService,
ISettingsManager settingsManager,
UserManager<ApplicationUser> userManager,
Func<UserManager<ApplicationUser>> userManagerFactory,
INotificationSearchService notificationSearchService,
ICustomerOrderService orderService)
{
Expand All @@ -48,7 +48,7 @@ public SendNotificationsOrderChangedEventHandler(
_memberService = memberService;
_settingsManager = settingsManager;
_notificationSearchService = notificationSearchService;
_userManager = userManager;
_userManagerFactory = userManagerFactory;
_orderService = orderService;
}

Expand Down Expand Up @@ -281,7 +281,8 @@ protected virtual async Task<string> GetCustomerEmailAsync(string customerId)
if (customer == null)
{
// try to find user
var user = await _userManager.FindByIdAsync(customerId);
using var userManager = _userManagerFactory();
var user = await userManager.FindByIdAsync(customerId);

return user?.Email;
}
Expand All @@ -296,7 +297,8 @@ protected virtual async Task<Member> GetCustomerAsync(string customerId)

if (result == null)
{
var user = await _userManager.FindByIdAsync(customerId);
using var userManager = _userManagerFactory();
var user = await userManager.FindByIdAsync(customerId);

if (user != null)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="8.0.0" PrivateAssets="All" />
<PackageReference Include="VirtoCommerce.CatalogModule.Core" Version="3.800.0" />
<PackageReference Include="VirtoCommerce.InventoryModule.Core" Version="3.800.0" />
<PackageReference Include="VirtoCommerce.Platform.Data" Version="3.800.0" />
<PackageReference Include="VirtoCommerce.Platform.Security" Version="3.800.0" />
<PackageReference Include="VirtoCommerce.Platform.Data" Version="3.825.0" />
<PackageReference Include="VirtoCommerce.Platform.Security" Version="3.825.0" />
<PackageReference Include="VirtoCommerce.SearchModule.Data" Version="3.800.0" />
</ItemGroup>
<ItemGroup>
Expand Down
17 changes: 7 additions & 10 deletions src/VirtoCommerce.OrdersModule.Web/Module.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@
using VirtoCommerce.OrdersModule.Web.Authorization;
using VirtoCommerce.OrdersModule.Web.Extensions;
using VirtoCommerce.OrdersModule.Web.JsonConverters;
using VirtoCommerce.Platform.Core.Bus;
using VirtoCommerce.Platform.Core.Common;
using VirtoCommerce.Platform.Core.DynamicProperties;
using VirtoCommerce.Platform.Core.Events;
using VirtoCommerce.Platform.Core.ExportImport;
using VirtoCommerce.Platform.Core.Modularity;
using VirtoCommerce.Platform.Core.Security;
Expand Down Expand Up @@ -94,9 +94,7 @@ public void Initialize(IServiceCollection serviceCollection)
serviceCollection.AddTransient<LogChangesOrderChangedEventHandler>();
serviceCollection.AddTransient<IndexCustomerOrderChangedEventHandler>();
serviceCollection.AddTransient<IPaymentFlowService, PaymentFlowService>();

//Register as scoped because we use UserManager<> as dependency in this implementation
serviceCollection.AddScoped<SendNotificationsOrderChangedEventHandler>();
serviceCollection.AddTransient<SendNotificationsOrderChangedEventHandler>();
serviceCollection.AddTransient<PolymorphicOperationJsonConverter>();

serviceCollection.AddTransient<IAuthorizationHandler, OrderAuthorizationHandler>();
Expand Down Expand Up @@ -179,12 +177,11 @@ public void PostInitialize(IApplicationBuilder appBuilder)
ModuleConstants.Security.Permissions.Delete,
}, new OnlyOrderResponsibleScope(), new OrderSelectedStoreScope());

var handlerRegistrar = appBuilder.ApplicationServices.GetService<IHandlerRegistrar>();
handlerRegistrar.RegisterHandler<OrderChangedEvent>((message, _) => appBuilder.ApplicationServices.GetService<AdjustInventoryOrderChangedEventHandler>().Handle(message));
handlerRegistrar.RegisterHandler<OrderChangedEvent>((message, _) => appBuilder.ApplicationServices.GetService<CancelPaymentOrderChangedEventHandler>().Handle(message));
handlerRegistrar.RegisterHandler<OrderChangedEvent>((message, _) => appBuilder.ApplicationServices.GetService<LogChangesOrderChangedEventHandler>().Handle(message));
handlerRegistrar.RegisterHandler<OrderChangedEvent>((message, _) => appBuilder.ApplicationServices.CreateScope().ServiceProvider.GetService<SendNotificationsOrderChangedEventHandler>().Handle(message));
handlerRegistrar.RegisterHandler<OrderChangedEvent>((message, _) => appBuilder.ApplicationServices.GetService<IndexCustomerOrderChangedEventHandler>().Handle(message));
appBuilder.RegisterEventHandler<OrderChangedEvent, AdjustInventoryOrderChangedEventHandler>();
appBuilder.RegisterEventHandler<OrderChangedEvent, CancelPaymentOrderChangedEventHandler>();
appBuilder.RegisterEventHandler<OrderChangedEvent, LogChangesOrderChangedEventHandler>();
appBuilder.RegisterEventHandler<OrderChangedEvent, SendNotificationsOrderChangedEventHandler>();
appBuilder.RegisterEventHandler<OrderChangedEvent, IndexCustomerOrderChangedEventHandler>();

if (fullTextSearchEnabled)
{
Expand Down
2 changes: 1 addition & 1 deletion src/VirtoCommerce.OrdersModule.Web/module.manifest
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<id>VirtoCommerce.Orders</id>
<version>3.815.0</version>
<version-tag />
<platformVersion>3.800.0</platformVersion>
<platformVersion>3.825.0</platformVersion>
<dependencies>
<dependency id="VirtoCommerce.Cart" version="3.800.0" />
<dependency id="VirtoCommerce.Catalog" version="3.800.0" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<IsPackable>false</IsPackable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="coverlet.collector" Version="6.0.0">
<PackageReference Include="coverlet.collector" Version="6.0.2">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
Expand Down

0 comments on commit 7d0540f

Please sign in to comment.