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.

Minor changes with event handlers: CustomerLoggedInEventHandler/CustomerLoggedOutEventHandler

KrzysztofPajakaeb36d8764b0
diff --git a/src/Business/Grand.Business.Marketing/Events/CustomerLoggedInEventHandler.cs b/src/Web/Grand.Web/Events/CustomerLoggedInEventHandler.cs
similarity index 67%
rename from src/Business/Grand.Business.Marketing/Events/CustomerLoggedInEventHandler.cs
rename to src/Web/Grand.Web/Events/CustomerLoggedInEventHandler.cs
index 18355f79a..43eba5f5a 100644
--- a/src/Business/Grand.Business.Marketing/Events/CustomerLoggedInEventHandler.cs
+++ b/src/Web/Grand.Web/Events/CustomerLoggedInEventHandler.cs
@@ -2,28 +2,35 @@
using Grand.Business.Common.Interfaces.Logging;
using Grand.Business.Customers.Events;
using MediatR;
+using Microsoft.AspNetCore.Http;
using System.Threading;
using System.Threading.Tasks;
-namespace Grand.Business.Marketing.Events
+namespace Grand.Web.Events
{
public class CustomerLoggedInEventHandler : INotificationHandler<CustomerLoggedInEvent>
{
private readonly ICustomerActivityService _customerActivityService;
+ private readonly IHttpContextAccessor _httpContextAccessor;
private readonly ITranslationService _translationService;
public CustomerLoggedInEventHandler(
ICustomerActivityService customerActivityService,
+ IHttpContextAccessor httpContextAccessor,
ITranslationService translationService)
{
_customerActivityService = customerActivityService;
+ _httpContextAccessor = httpContextAccessor;
_translationService = translationService;
}
public Task Handle(CustomerLoggedInEvent notification, CancellationToken cancellationToken)
{
//activity log
- _ = _customerActivityService.InsertActivity("PublicStore.Login", notification.Customer.Id, notification.Customer, "", _translationService.GetResource("ActivityLog.PublicStore.Login"));
+ _ = _customerActivityService.InsertActivity("PublicStore.Login",
+ notification.Customer.Id, notification.Customer,
+ _httpContextAccessor.HttpContext?.Connection?.RemoteIpAddress?.ToString(),
+ _translationService.GetResource("ActivityLog.PublicStore.Login"));
return Task.CompletedTask;
}
}
diff --git a/src/Business/Grand.Business.Marketing/Events/CustomerLoggedOutEventHandler.cs b/src/Web/Grand.Web/Events/CustomerLoggedOutEventHandler.cs
similarity index 69%
rename from src/Business/Grand.Business.Marketing/Events/CustomerLoggedOutEventHandler.cs
rename to src/Web/Grand.Web/Events/CustomerLoggedOutEventHandler.cs
index 6c0e55bba..47f6dd20c 100644
--- a/src/Business/Grand.Business.Marketing/Events/CustomerLoggedOutEventHandler.cs
+++ b/src/Web/Grand.Web/Events/CustomerLoggedOutEventHandler.cs
@@ -2,28 +2,34 @@
using Grand.Business.Common.Interfaces.Logging;
using Grand.Business.Customers.Events;
using MediatR;
+using Microsoft.AspNetCore.Http;
using System.Threading;
using System.Threading.Tasks;
-namespace Grand.Business.Marketing.Events
+namespace Grand.Web.Events
{
public class CustomerLoggedOutEventHandler : INotificationHandler<CustomerLoggedOutEvent>
{
private readonly ICustomerActivityService _customerActivityService;
+ private readonly IHttpContextAccessor _httpContextAccessor;
private readonly ITranslationService _translationService;
public CustomerLoggedOutEventHandler(
ICustomerActivityService customerActivityService,
+ IHttpContextAccessor httpContextAccessor,
ITranslationService translationService)
{
_customerActivityService = customerActivityService;
+ _httpContextAccessor = httpContextAccessor;
_translationService = translationService;
}
public Task Handle(CustomerLoggedOutEvent notification, CancellationToken cancellationToken)
{
//activity log
- _ = _customerActivityService.InsertActivity("PublicStore.Logout", "", notification.Customer, "", _translationService.GetResource("ActivityLog.PublicStore.Logout"));
+ _ = _customerActivityService.InsertActivity("PublicStore.Logout", "", notification.Customer,
+ _httpContextAccessor.HttpContext?.Connection?.RemoteIpAddress?.ToString(),
+ _translationService.GetResource("ActivityLog.PublicStore.Logout"));
return Task.CompletedTask;
}
}