Skip to content

Commit

Permalink
Init event handlers
Browse files Browse the repository at this point in the history
  • Loading branch information
fernandoareias committed Jan 11, 2024
1 parent b2c1283 commit a31b998
Show file tree
Hide file tree
Showing 34 changed files with 607 additions and 7 deletions.
37 changes: 37 additions & 0 deletions Notification.sln
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,20 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Notification.API", "src\API
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Notification.Worker", "src\Worker\Notification.Worker\Notification.Worker.csproj", "{0F85D6DF-9856-49A7-B8E0-DD852E4005DA}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "api", "api", "{B8736E0D-E30F-45F4-8AD6-35DC14CAA2F9}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "core", "core", "{BD163528-E6C5-4590-9827-EE79EFAC28B9}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "worker", "worker", "{09B869A3-6ADB-4CFE-8366-85D6F7FD86A9}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Notification.API.Tests", "tests\API\Notification.API.Tests\Notification.API.Tests.csproj", "{12FD847F-6349-454F-9746-FF325FE739CC}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Notification.Core.Tests", "tests\Core\Notification.Core.Tests\Notification.Core.Tests.csproj", "{F2E172DE-C445-4B27-86BA-D9E085AD5009}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TestProject1Notification.Core.MessageBus.Tests", "tests\Core\TestProject1Notification.Core.MessageBus.Tests\TestProject1Notification.Core.MessageBus.Tests.csproj", "{981DB2FA-D1AF-4332-B443-CDED0C5D5295}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TestProject1Notification.Worker.Tests", "tests\Worker\TestProject1Notification.Worker.Tests\TestProject1Notification.Worker.Tests.csproj", "{843D91D0-B11C-40A5-A12F-DCDFE1840274}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand All @@ -37,6 +51,13 @@ Global
{59EB325D-5710-4BB2-A7EE-86B1FD25D1E5} = {5B9160EC-64B5-47F8-A393-7C498BEBEF7A}
{C0358355-BCED-4196-AB73-CF0DF70E80E5} = {81CBFB0D-50C3-4AB5-9637-C348238439AC}
{0F85D6DF-9856-49A7-B8E0-DD852E4005DA} = {89DDB75D-4397-42D1-B58C-86F2AD4CC0F4}
{B8736E0D-E30F-45F4-8AD6-35DC14CAA2F9} = {A867D592-46DD-4FEE-A19A-412399603CB6}
{BD163528-E6C5-4590-9827-EE79EFAC28B9} = {A867D592-46DD-4FEE-A19A-412399603CB6}
{09B869A3-6ADB-4CFE-8366-85D6F7FD86A9} = {A867D592-46DD-4FEE-A19A-412399603CB6}
{12FD847F-6349-454F-9746-FF325FE739CC} = {B8736E0D-E30F-45F4-8AD6-35DC14CAA2F9}
{F2E172DE-C445-4B27-86BA-D9E085AD5009} = {BD163528-E6C5-4590-9827-EE79EFAC28B9}
{981DB2FA-D1AF-4332-B443-CDED0C5D5295} = {BD163528-E6C5-4590-9827-EE79EFAC28B9}
{843D91D0-B11C-40A5-A12F-DCDFE1840274} = {09B869A3-6ADB-4CFE-8366-85D6F7FD86A9}
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{6742457B-5D96-4496-A4CE-2CCFA929ABF1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
Expand All @@ -55,5 +76,21 @@ Global
{0F85D6DF-9856-49A7-B8E0-DD852E4005DA}.Debug|Any CPU.Build.0 = Debug|Any CPU
{0F85D6DF-9856-49A7-B8E0-DD852E4005DA}.Release|Any CPU.ActiveCfg = Release|Any CPU
{0F85D6DF-9856-49A7-B8E0-DD852E4005DA}.Release|Any CPU.Build.0 = Release|Any CPU
{12FD847F-6349-454F-9746-FF325FE739CC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{12FD847F-6349-454F-9746-FF325FE739CC}.Debug|Any CPU.Build.0 = Debug|Any CPU
{12FD847F-6349-454F-9746-FF325FE739CC}.Release|Any CPU.ActiveCfg = Release|Any CPU
{12FD847F-6349-454F-9746-FF325FE739CC}.Release|Any CPU.Build.0 = Release|Any CPU
{F2E172DE-C445-4B27-86BA-D9E085AD5009}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{F2E172DE-C445-4B27-86BA-D9E085AD5009}.Debug|Any CPU.Build.0 = Debug|Any CPU
{F2E172DE-C445-4B27-86BA-D9E085AD5009}.Release|Any CPU.ActiveCfg = Release|Any CPU
{F2E172DE-C445-4B27-86BA-D9E085AD5009}.Release|Any CPU.Build.0 = Release|Any CPU
{981DB2FA-D1AF-4332-B443-CDED0C5D5295}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{981DB2FA-D1AF-4332-B443-CDED0C5D5295}.Debug|Any CPU.Build.0 = Debug|Any CPU
{981DB2FA-D1AF-4332-B443-CDED0C5D5295}.Release|Any CPU.ActiveCfg = Release|Any CPU
{981DB2FA-D1AF-4332-B443-CDED0C5D5295}.Release|Any CPU.Build.0 = Release|Any CPU
{843D91D0-B11C-40A5-A12F-DCDFE1840274}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{843D91D0-B11C-40A5-A12F-DCDFE1840274}.Debug|Any CPU.Build.0 = Debug|Any CPU
{843D91D0-B11C-40A5-A12F-DCDFE1840274}.Release|Any CPU.ActiveCfg = Release|Any CPU
{843D91D0-B11C-40A5-A12F-DCDFE1840274}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
EndGlobal
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
using System.Runtime.Serialization;
using Notification.Core.Common.CQRS;

namespace Notification.Worker.Application.Commands.Send.Base;

public abstract class RetrySendNotificationCommand : Command
{
protected RetrySendNotificationCommand(string correlationId)
{
CorrelationId = correlationId;
}

[DataMember]
public string CorrelationId { get; private set; }
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
using MediatR;
using Microsoft.AspNetCore.Mvc;
using Notification.Core.Common.Domain;
using Notification.Worker.Data.Repositories.Interfaces;
using Notification.Worker.Domain.Services.Interfaces;

namespace Notification.Worker.Application.Commands.Handlers;

public class RetrySendNotificationEmailCommandHandler : IRequestHandler<RetrySendNotificationEmailCommand, IActionResult>
{
public RetrySendNotificationEmailCommandHandler(INotificationRepository notificationRepository, IEmailServices emailServices)
{
_notificationRepository = notificationRepository;
_emailServices = emailServices;
}

private readonly INotificationRepository _notificationRepository;
private readonly IEmailServices _emailServices;

public async Task<IActionResult> Handle(RetrySendNotificationEmailCommand request, CancellationToken cancellationToken)
{
Domain.Notification notification = await _notificationRepository.GetByCorrelationId(request.AggregateId);

if (notification == null)
throw new DomainException("Notification not exists.");

await notification.Send(_emailServices);

_notificationRepository.Update(notification);

await _notificationRepository.unitOfWork.Commit();

return new OkResult();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
using MediatR;
using Microsoft.AspNetCore.Mvc;
using Notification.Core.Common.Domain;
using Notification.Worker.Data.Repositories.Interfaces;
using Notification.Worker.Domain.Services.Interfaces;

namespace Notification.Worker.Application.Commands.Handlers;

public class RetrySendNotificationLetterCommandHandler : IRequestHandler<RetrySendNotificationLetterCommand, IActionResult>
{
public RetrySendNotificationLetterCommandHandler(INotificationRepository notificationRepository, IEmailServices emailServices)
{
_notificationRepository = notificationRepository;
_emailServices = emailServices;
}

private readonly INotificationRepository _notificationRepository;
private readonly IEmailServices _emailServices;

public async Task<IActionResult> Handle(RetrySendNotificationLetterCommand request, CancellationToken cancellationToken)
{
Domain.Notification notification = await _notificationRepository.GetByCorrelationId(request.AggregateId);

if (notification == null)
throw new DomainException("Notification not exists.");

await notification.Send(_emailServices);

_notificationRepository.Update(notification);

await _notificationRepository.unitOfWork.Commit();

return new OkResult();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
using MediatR;
using Microsoft.AspNetCore.Mvc;
using Notification.Core.Common.Domain;
using Notification.Worker.Data.Repositories.Interfaces;
using Notification.Worker.Domain.Services.Interfaces;

namespace Notification.Worker.Application.Commands.Handlers;

public class RetrySendNotificationPushCommandHandler : IRequestHandler<RetrySendNotificationPushCommand, IActionResult>
{
public RetrySendNotificationPushCommandHandler(INotificationRepository notificationRepository, IEmailServices emailServices)
{
_notificationRepository = notificationRepository;
_emailServices = emailServices;
}

private readonly INotificationRepository _notificationRepository;
private readonly IEmailServices _emailServices;

public async Task<IActionResult> Handle(RetrySendNotificationPushCommand request, CancellationToken cancellationToken)
{
Domain.Notification notification = await _notificationRepository.GetByCorrelationId(request.AggregateId);

if (notification == null)
throw new DomainException("Notification not exists.");

await notification.Send(_emailServices);

_notificationRepository.Update(notification);

await _notificationRepository.unitOfWork.Commit();

return new OkResult();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
using MediatR;
using Microsoft.AspNetCore.Mvc;
using Notification.Core.Common.Domain;
using Notification.Worker.Data.Repositories.Interfaces;
using Notification.Worker.Domain.Services.Interfaces;

namespace Notification.Worker.Application.Commands.Handlers;

public class RetrySendNotificationSMSCommandHandler : IRequestHandler<RetrySendNotificationSMSCommand, IActionResult>
{
public RetrySendNotificationSMSCommandHandler(INotificationRepository notificationRepository, IEmailServices emailServices)
{
_notificationRepository = notificationRepository;
_emailServices = emailServices;
}

private readonly INotificationRepository _notificationRepository;
private readonly IEmailServices _emailServices;

public async Task<IActionResult> Handle(RetrySendNotificationSMSCommand request, CancellationToken cancellationToken)
{
Domain.Notification notification = await _notificationRepository.GetByCorrelationId(request.AggregateId);

if (notification == null)
throw new DomainException("Notification not exists.");

await notification.Send(_emailServices);

_notificationRepository.Update(notification);

await _notificationRepository.unitOfWork.Commit();

return new OkResult();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
using MediatR;
using Microsoft.AspNetCore.Mvc;
using Notification.Core.Common.Domain;
using Notification.Worker.Data.Repositories.Interfaces;
using Notification.Worker.Domain.Services.Interfaces;

namespace Notification.Worker.Application.Commands.Handlers;

public class RetrySendNotificationWhatsAppCommandHandler : IRequestHandler<RetrySendNotificationWhatsAppCommand, IActionResult>
{
public RetrySendNotificationWhatsAppCommandHandler(INotificationRepository notificationRepository, IEmailServices emailServices)
{
_notificationRepository = notificationRepository;
_emailServices = emailServices;
}

private readonly INotificationRepository _notificationRepository;
private readonly IEmailServices _emailServices;

public async Task<IActionResult> Handle(RetrySendNotificationWhatsAppCommand request, CancellationToken cancellationToken)
{
Domain.Notification notification = await _notificationRepository.GetByCorrelationId(request.AggregateId);

if (notification == null)
throw new DomainException("Notification not exists.");

await notification.Send(_emailServices);

_notificationRepository.Update(notification);

await _notificationRepository.unitOfWork.Commit();

return new OkResult();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
using Notification.Core.Common.CQRS;
using Notification.Worker.Application.Commands.Send.Base;

namespace Notification.Worker.Application.Commands;

public class RetrySendNotificationEmailCommand : RetrySendNotificationCommand
{
public RetrySendNotificationEmailCommand(string correlationId) : base(correlationId)
{

}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
using Notification.Worker.Application.Commands.Send.Base;

namespace Notification.Worker.Application.Commands;

public class RetrySendNotificationLetterCommand : RetrySendNotificationCommand
{
public RetrySendNotificationLetterCommand(string correlationId) : base(correlationId)
{

}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
using Notification.Worker.Application.Commands.Send.Base;

namespace Notification.Worker.Application.Commands;

public class RetrySendNotificationPushCommand : RetrySendNotificationCommand
{
public RetrySendNotificationPushCommand(string correlationId) : base(correlationId)
{

}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
using System.Runtime.Serialization;
using Notification.Core.Common.CQRS;
using Notification.Core.Domain.Enums;
using Notification.Worker.Application.Commands.Send.Base;

namespace Notification.Worker.Application.Commands;

public class RetrySendNotificationSMSCommand : RetrySendNotificationCommand
{
public RetrySendNotificationSMSCommand(string correlationId) : base(correlationId)
{

}

}


Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
using Notification.Worker.Application.Commands.Send.Base;

namespace Notification.Worker.Application.Commands;

public class RetrySendNotificationWhatsAppCommand : RetrySendNotificationCommand
{
public RetrySendNotificationWhatsAppCommand(string correlationId) : base(correlationId)
{

}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
using MediatR;

namespace Notification.Worker.Domain.Events.Handlers;

public class NotificationEmailDeliveryFailureEventHandler : INotificationHandler<NotificationEmailDeliveryFailureEvent>
{
public Task Handle(NotificationEmailDeliveryFailureEvent notification, CancellationToken cancellationToken)
{
throw new NotImplementedException();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
using MediatR;

namespace Notification.Worker.Domain.Events.Handlers;

public class NotificationLetterDeliveryFailureEventHandler : INotificationHandler<NotificationLetterDeliveryFailureEvent>
{
public Task Handle(NotificationLetterDeliveryFailureEvent notification, CancellationToken cancellationToken)
{
throw new NotImplementedException();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
using MediatR;

namespace Notification.Worker.Domain.Events.Handlers;

public class NotificationPushDeliveryFailureEventHandler : INotificationHandler<NotificationPushDeliveryFailureEvent>
{
public Task Handle(NotificationPushDeliveryFailureEvent notification, CancellationToken cancellationToken)
{
throw new NotImplementedException();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
using MediatR;

namespace Notification.Worker.Domain.Events.Handlers;

public class NotificationSMSDeliveryFailureEventHandler : INotificationHandler<NotificationSMSDeliveryFailureEvent>
{
public Task Handle(NotificationSMSDeliveryFailureEvent notification, CancellationToken cancellationToken)
{
throw new NotImplementedException();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
using MediatR;

namespace Notification.Worker.Domain.Events.Handlers;

public class NotificationWhatsAppDeliveryFailureEventHandler : INotificationHandler<NotificationWhatsAppDeliveryFailureEvent>
{
public Task Handle(NotificationWhatsAppDeliveryFailureEvent notification, CancellationToken cancellationToken)
{
throw new NotImplementedException();
}
}
Loading

0 comments on commit a31b998

Please sign in to comment.