Completed refactor

This commit is contained in:
Khwezi Mngoma
2026-05-14 01:33:21 +02:00
parent 42001998d6
commit 134d8429c0
129 changed files with 1870 additions and 3165 deletions
@@ -1,22 +1,27 @@
using LiteCharms.Features.Notifications.Commands;
using LiteCharms.Features.Shop;
using LiteCharms.Features.Shop;
using LiteCharms.Features.Shop.Notifications;
using static LiteCharms.Features.Email.Extensions.Constants;
namespace LiteCharms.Features.Email.Events.Handlers;
// TODO: Inject the INotificationService
public class SendShopEmailEnquiryEventHandler(ISender mediator) :
public class SendShopEmailEnquiryEventHandler(NotificationService notificationService) :
INotificationHandler<SendShopEmailEnquiryEvent>
{
public async ValueTask Handle(SendShopEmailEnquiryEvent notification, CancellationToken cancellationToken)
{
// TODO: Refactor this to use the NotificationService
var command = CreateNotification.Create(NotificationDirection.Outgoing, notification.SenderName!,
notification.SenderAddress!, notification.Subject!, notification.Message!, NotificationPlatforms.Email,
notification.Priority, ShopEmailFromName, ShopEmailFromAddress, Guid.CreateVersion7().ToString(),
CorrelationIdTypes.None, isInternal: true, isHtml: false);
// TODO: Remove, deprecated
await mediator.Send(command, cancellationToken);
}
public async ValueTask Handle(SendShopEmailEnquiryEvent notification, CancellationToken cancellationToken) =>
await notificationService.CreateNotificationAsync(new Shop.Notifications.Models.CreateNotification
{
CorrelationId = notification.CorrelationId,
CorrelationIdType = CorrelationIdTypes.None,
Direction = NotificationDirection.Outgoing,
IsHtml = false,
IsInternal = true,
Message = notification.Message,
Platform = NotificationPlatforms.Email,
Priority = notification.Priority,
Subject = notification.Subject!,
Sender = notification.SenderName!,
SenderAddress = notification.SenderAddress!,
Recipient = ShopEmailFromName,
RecipientAddress = ShopEmailFromAddress
}, cancellationToken);
}