diff --git a/EstateManagement.BusinessLogic.Tests/EstateManagement.BusinessLogic.Tests.csproj b/EstateManagement.BusinessLogic.Tests/EstateManagement.BusinessLogic.Tests.csproj
index 7df72663..d5b898f8 100644
--- a/EstateManagement.BusinessLogic.Tests/EstateManagement.BusinessLogic.Tests.csproj
+++ b/EstateManagement.BusinessLogic.Tests/EstateManagement.BusinessLogic.Tests.csproj
@@ -14,7 +14,7 @@
-
+
diff --git a/EstateManagement.BusinessLogic.Tests/EventHandling/EstateDomainEventHandlerTests.cs b/EstateManagement.BusinessLogic.Tests/EventHandling/EstateDomainEventHandlerTests.cs
index 59600b4d..ee95081e 100644
--- a/EstateManagement.BusinessLogic.Tests/EventHandling/EstateDomainEventHandlerTests.cs
+++ b/EstateManagement.BusinessLogic.Tests/EventHandling/EstateDomainEventHandlerTests.cs
@@ -1,4 +1,6 @@
-namespace EstateManagement.BusinessLogic.Tests.EventHandling;
+using SimpleResults;
+
+namespace EstateManagement.BusinessLogic.Tests.EventHandling;
using System.Threading;
using BusinessLogic.EventHandling;
@@ -28,6 +30,9 @@ public EstateDomainEventHandlerTests() {
public void EstateDomainEventHandler_EstateCreatedEvent_EventIsHandled()
{
EstateCreatedEvent estateCreatedEvent = TestData.EstateCreatedEvent;
+ this.EstateReportingRepository
+ .Setup(r => r.CreateReadModel(It.IsAny(), It.IsAny()))
+ .ReturnsAsync(Result.Success);
Should.NotThrow(async () => { await this.DomainEventHandler.Handle(estateCreatedEvent, CancellationToken.None); });
}
diff --git a/EstateManagement.BusinessLogic.Tests/EventHandling/MerchantSettlementDomainEventHandlerTests.cs b/EstateManagement.BusinessLogic.Tests/EventHandling/MerchantSettlementDomainEventHandlerTests.cs
index 0798c843..7368532e 100644
--- a/EstateManagement.BusinessLogic.Tests/EventHandling/MerchantSettlementDomainEventHandlerTests.cs
+++ b/EstateManagement.BusinessLogic.Tests/EventHandling/MerchantSettlementDomainEventHandlerTests.cs
@@ -1,4 +1,6 @@
-namespace EstateManagement.BusinessLogic.Tests.EventHandling;
+using SimpleResults;
+
+namespace EstateManagement.BusinessLogic.Tests.EventHandling;
using System.Threading;
using System.Threading.Tasks;
@@ -24,12 +26,12 @@ public MerchantSettlementDomainEventHandlerTests(){
[Fact]
public async Task MerchantSettlementDomainEventHandler_Handle_MerchantFeeSettledEvent_EventIsHandled()
{
- this.Mediator.Setup(m => m.Send(It.IsAny(), It.IsAny())).Returns(Task.CompletedTask);
+ this.Mediator.Setup(m => m.Send(It.IsAny>(), It.IsAny())).ReturnsAsync(Result.Success);
Should.NotThrow(async () =>
{
await this.DomainEventHandler.Handle(TestData.MerchantFeeSettledEvent, CancellationToken.None);
});
- this.Mediator.Verify(m => m.Send(It.IsAny(), It.IsAny()), Times.Once);
+ this.Mediator.Verify(m => m.Send(It.IsAny>(), It.IsAny()), Times.Once);
}
[Fact]
diff --git a/EstateManagement.BusinessLogic.Tests/EventHandling/MerchantStatementDomainEventHandlerTests.cs b/EstateManagement.BusinessLogic.Tests/EventHandling/MerchantStatementDomainEventHandlerTests.cs
index 030a47c8..fc985e42 100644
--- a/EstateManagement.BusinessLogic.Tests/EventHandling/MerchantStatementDomainEventHandlerTests.cs
+++ b/EstateManagement.BusinessLogic.Tests/EventHandling/MerchantStatementDomainEventHandlerTests.cs
@@ -1,4 +1,6 @@
-namespace EstateManagement.BusinessLogic.Tests.EventHandling;
+using SimpleResults;
+
+namespace EstateManagement.BusinessLogic.Tests.EventHandling;
using System.Threading;
using System.Threading.Tasks;
@@ -25,22 +27,22 @@ public MerchantStatementDomainEventHandlerTests()
[Fact]
public async Task MerchantStatementDomainEventHandler_Handle_StatementGeneratedEvent_EventIsHandled()
{
- this.Mediator.Setup(m => m.Send(It.IsAny(), It.IsAny())).Returns(Task.CompletedTask);
+ this.Mediator.Setup(m => m.Send(It.IsAny>(), It.IsAny())).ReturnsAsync(Result.Success());
Should.NotThrow(async () =>
{
await this.DomainEventHandler.Handle(TestData.StatementGeneratedEvent, CancellationToken.None);
});
- this.Mediator.Verify(m=> m.Send(It.IsAny(), It.IsAny()), Times.Once);
+ this.Mediator.Verify(m=> m.Send(It.IsAny>(), It.IsAny()), Times.Once);
}
[Fact]
public async Task MerchantStatementDomainEventHandler_Handle_TransactionHasBeenCompletedEvent_EventIsHandled()
{
- this.Mediator.Setup(m => m.Send(It.IsAny(), It.IsAny())).Returns(Task.CompletedTask);
+ this.Mediator.Setup(m => m.Send(It.IsAny>(), It.IsAny())).ReturnsAsync(Result.Success());
Should.NotThrow(async () =>
{
await this.DomainEventHandler.Handle(TestData.TransactionHasBeenCompletedEvent, CancellationToken.None);
});
- this.Mediator.Verify(m => m.Send(It.IsAny(), It.IsAny()), Times.Once);
+ this.Mediator.Verify(m => m.Send(It.IsAny>(), It.IsAny()), Times.Once);
}
}
\ No newline at end of file
diff --git a/EstateManagement.BusinessLogic.Tests/EventHandling/TransactionDomainEventHandlerTests.cs b/EstateManagement.BusinessLogic.Tests/EventHandling/TransactionDomainEventHandlerTests.cs
index 5e0f1251..7ebf3f69 100644
--- a/EstateManagement.BusinessLogic.Tests/EventHandling/TransactionDomainEventHandlerTests.cs
+++ b/EstateManagement.BusinessLogic.Tests/EventHandling/TransactionDomainEventHandlerTests.cs
@@ -7,6 +7,7 @@ namespace EstateManagement.BusinessLogic.Tests.EventHandling
using MediatR;
using Moq;
using Repository;
+ using Shared.DomainDrivenDesign.EventSourcing;
using Shared.Logger;
using Shouldly;
using Testing;
@@ -47,6 +48,10 @@ public void TransactionDomainEventHandler_AdditionalRequestDataRecordedEvent_Eve
Logger.Initialise(NullLogger.Instance);
+ this.EstateReportingRepository
+ .Setup(r => r.RecordTransactionAdditionalRequestData(It.IsAny(), It.IsAny()))
+ .ReturnsAsync(SimpleResults.Result.Success);
+
Should.NotThrow(async () => { await this.DomainEventHandler.Handle(additionalRequestDataRecordedEvent, CancellationToken.None); });
}
diff --git a/EstateManagement.BusinessLogic.Tests/Mediator/DummyMerchantStatementDomainService.cs b/EstateManagement.BusinessLogic.Tests/Mediator/DummyMerchantStatementDomainService.cs
index 41256098..878aade6 100644
--- a/EstateManagement.BusinessLogic.Tests/Mediator/DummyMerchantStatementDomainService.cs
+++ b/EstateManagement.BusinessLogic.Tests/Mediator/DummyMerchantStatementDomainService.cs
@@ -18,15 +18,15 @@ namespace EstateManagement.BusinessLogic.Tests.Mediator;
using Operator = Models.Operator.Operator;
public class DummyMerchantStatementDomainService : IMerchantStatementDomainService{
- public async Task AddTransactionToStatement(AddTransactionToMerchantStatementRequest command,
+ public async Task AddTransactionToStatement(MerchantStatementCommands.AddTransactionToMerchantStatementCommand command,
CancellationToken cancellationToken) => Result.Success();
- public async Task AddSettledFeeToStatement(AddSettledFeeToMerchantStatementRequest command,
+ public async Task AddSettledFeeToStatement(MerchantStatementCommands.AddSettledFeeToMerchantStatementCommand command,
CancellationToken cancellationToken) => Result.Success();
public async Task GenerateStatement(MerchantCommands.GenerateMerchantStatementCommand command, CancellationToken cancellationToken) => Result.Success();
- public async Task EmailStatement(EmailMerchantStatementRequest command,
+ public async Task EmailStatement(MerchantStatementCommands.EmailMerchantStatementCommand command,
CancellationToken cancellationToken) => Result.Success();
}
diff --git a/EstateManagement.BusinessLogic.Tests/Requests/RequestsTests.cs b/EstateManagement.BusinessLogic.Tests/Requests/RequestsTests.cs
deleted file mode 100644
index 34bf5662..00000000
--- a/EstateManagement.BusinessLogic.Tests/Requests/RequestsTests.cs
+++ /dev/null
@@ -1,68 +0,0 @@
-namespace EstateManagement.BusinessLogic.Tests.Commands
-{
- using Models;
- using Models.Contract;
- using Requests;
- using Shouldly;
- using Testing;
- using Xunit;
-
- public class RequestsTests
- {
- #region Methods
-
- [Fact]
- public void AddSettledFeeToMerchantStatementRequest_CanBeCreated_IsCreated() {
- AddSettledFeeToMerchantStatementRequest addSettledFeeToMerchantStatementRequest =
- AddSettledFeeToMerchantStatementRequest.Create(TestData.EstateId,
- TestData.MerchantId,
- TestData.SettledFeeDateTime1,
- TestData.SettledFeeAmount1,
- TestData.TransactionId1,
- TestData.SettledFeeId1);
-
- addSettledFeeToMerchantStatementRequest.ShouldNotBeNull();
- addSettledFeeToMerchantStatementRequest.SettledDateTime.ShouldBe(TestData.SettledFeeDateTime1);
- addSettledFeeToMerchantStatementRequest.SettledFeeId.ShouldBe(TestData.SettledFeeId1);
- addSettledFeeToMerchantStatementRequest.SettledAmount.ShouldBe(TestData.SettledFeeAmount1);
- addSettledFeeToMerchantStatementRequest.TransactionId.ShouldBe(TestData.TransactionId1);
- addSettledFeeToMerchantStatementRequest.EstateId.ShouldBe(TestData.EstateId);
- addSettledFeeToMerchantStatementRequest.MerchantId.ShouldBe(TestData.MerchantId);
- }
-
-
-
- [Fact]
- public void AddTransactionToMerchantStatementRequest_CanBeCreated_IsCreated() {
- AddTransactionToMerchantStatementRequest addTransactionToMerchantStatementRequest =
- AddTransactionToMerchantStatementRequest.Create(TestData.EstateId,
- TestData.MerchantId,
- TestData.TransactionDateTime1,
- TestData.TransactionAmount1,
- TestData.IsAuthorisedTrue,
- TestData.TransactionId1);
-
- addTransactionToMerchantStatementRequest.ShouldNotBeNull();
- addTransactionToMerchantStatementRequest.IsAuthorised.ShouldBe(TestData.IsAuthorisedTrue);
- addTransactionToMerchantStatementRequest.TransactionAmount.ShouldBe(TestData.TransactionAmount1);
- addTransactionToMerchantStatementRequest.TransactionDateTime.ShouldBe(TestData.TransactionDateTime1);
- addTransactionToMerchantStatementRequest.TransactionId.ShouldBe(TestData.TransactionId1);
- addTransactionToMerchantStatementRequest.EstateId.ShouldBe(TestData.EstateId);
- addTransactionToMerchantStatementRequest.MerchantId.ShouldBe(TestData.MerchantId);
- }
-
-
- [Fact]
- public void EmailMerchantStatementRequest_CanBeCreated_IsCreated(){
- EmailMerchantStatementRequest emailMerchantStatementRequest =
- EmailMerchantStatementRequest.Create(TestData.EstateId, TestData.MerchantId, TestData.MerchantStatementId);
-
- emailMerchantStatementRequest.ShouldNotBeNull();
- emailMerchantStatementRequest.EstateId.ShouldBe(TestData.EstateId);
- emailMerchantStatementRequest.MerchantId.ShouldBe(TestData.MerchantId);
- emailMerchantStatementRequest.MerchantStatementId.ShouldBe(TestData.MerchantStatementId);
- }
-
- #endregion
- }
-}
\ No newline at end of file
diff --git a/EstateManagement.BusinessLogic.Tests/Services/MerchantStatementDomainServiceTests.cs b/EstateManagement.BusinessLogic.Tests/Services/MerchantStatementDomainServiceTests.cs
index 8c6924d9..8888f462 100644
--- a/EstateManagement.BusinessLogic.Tests/Services/MerchantStatementDomainServiceTests.cs
+++ b/EstateManagement.BusinessLogic.Tests/Services/MerchantStatementDomainServiceTests.cs
@@ -64,7 +64,7 @@ public async Task MerchantStatementDomainService_AddTransactionToStatement_Trans
merchantStatementAggregateRepository.Setup(m => m.GetLatestVersion(It.IsAny(), It.IsAny()))
.ReturnsAsync(Result.Success(merchantStatementAggregate));
- AddTransactionToMerchantStatementRequest command = AddTransactionToMerchantStatementRequest.Create(TestData.EstateId,
+ MerchantStatementCommands.AddTransactionToMerchantStatementCommand command = new(TestData.EstateId,
TestData.MerchantId,
TestData.TransactionDateTime1,
TestData.TransactionAmount1,
@@ -89,8 +89,8 @@ public async Task MerchantStatementDomainService_AddTransactionToStatement_Trans
merchantStatementAggregateRepository.Setup(m => m.GetLatestVersionFromLastEvent(It.IsAny(), It.IsAny()))
.ReturnsAsync(Result.Success(merchantStatementAggregate));
-
- AddTransactionToMerchantStatementRequest command = AddTransactionToMerchantStatementRequest.Create(TestData.EstateId,
+
+ MerchantStatementCommands.AddTransactionToMerchantStatementCommand command = new(TestData.EstateId,
TestData.MerchantId,
TestData.TransactionDateTime1,
TestData.TransactionAmount1,
@@ -115,8 +115,7 @@ public async Task MerchantStatementDomainService_AddTransactionToStatement_Logon
merchantStatementAggregateRepository.Setup(m => m.GetLatestVersionFromLastEvent(It.IsAny(), It.IsAny()))
.ReturnsAsync(Result.Success(merchantStatementAggregate));
- AddTransactionToMerchantStatementRequest command =
- AddTransactionToMerchantStatementRequest.Create(TestData.EstateId, TestData.MerchantId,
+ MerchantStatementCommands.AddTransactionToMerchantStatementCommand command = new(TestData.EstateId, TestData.MerchantId,
TestData.TransactionDateTime1, null, TestData.IsAuthorisedTrue, TestData.TransactionId1);
var result = await merchantStatementDomainService.AddTransactionToStatement(command, CancellationToken.None);
@@ -137,7 +136,7 @@ public async Task MerchantStatementDomainService_AddTransactionToStatement_State
merchantStatementAggregateRepository.Setup(m => m.GetLatestVersion(It.IsAny(), It.IsAny()))
.ReturnsAsync(Result.Success(merchantStatementAggregate));
- AddTransactionToMerchantStatementRequest command = AddTransactionToMerchantStatementRequest.Create(TestData.EstateId,
+ MerchantStatementCommands.AddTransactionToMerchantStatementCommand command = new(TestData.EstateId,
TestData.MerchantId,
TestData.TransactionDateTime1,
TestData.TransactionAmount1,
@@ -163,7 +162,7 @@ public async Task MerchantStatementDomainService_AddSettledFeeToStatement_Settle
merchantStatementAggregateRepository.Setup(m => m.GetLatestVersion(It.IsAny(), It.IsAny()))
.ReturnsAsync(Result.Success(merchantStatementAggregate));
- AddSettledFeeToMerchantStatementRequest command = AddSettledFeeToMerchantStatementRequest.Create(TestData.EstateId,
+ MerchantStatementCommands.AddSettledFeeToMerchantStatementCommand command = new(TestData.EstateId,
TestData.MerchantId,
TestData.SettledFeeDateTime1,
TestData.SettledFeeAmount1,
@@ -227,7 +226,7 @@ public async Task MerchantStatementDomainService_EmailStatement_StatementGenerat
.Setup(m => m.SendEmail(It.IsAny(), It.IsAny(),
It.IsAny())).ReturnsAsync(new SendEmailResponse { MessageId = Guid.NewGuid() });
- EmailMerchantStatementRequest command = EmailMerchantStatementRequest.Create(TestData.EstateId, TestData.MerchantId,
+ MerchantStatementCommands.EmailMerchantStatementCommand command = new(TestData.EstateId, TestData.MerchantId,
TestData.MerchantStatementId);
var result = await merchantStatementDomainService.EmailStatement(command, CancellationToken.None);
diff --git a/EstateManagement.BusinessLogic/EstateManagement.BusinessLogic.csproj b/EstateManagement.BusinessLogic/EstateManagement.BusinessLogic.csproj
index 30823aa0..4d19debc 100644
--- a/EstateManagement.BusinessLogic/EstateManagement.BusinessLogic.csproj
+++ b/EstateManagement.BusinessLogic/EstateManagement.BusinessLogic.csproj
@@ -8,7 +8,7 @@
-
+
diff --git a/EstateManagement.BusinessLogic/EventHandling/ContractDomainEventHandler.cs b/EstateManagement.BusinessLogic/EventHandling/ContractDomainEventHandler.cs
index e5ac6a01..71635eaf 100644
--- a/EstateManagement.BusinessLogic/EventHandling/ContractDomainEventHandler.cs
+++ b/EstateManagement.BusinessLogic/EventHandling/ContractDomainEventHandler.cs
@@ -1,4 +1,6 @@
-namespace EstateManagement.BusinessLogic.EventHandling;
+using SimpleResults;
+
+namespace EstateManagement.BusinessLogic.EventHandling;
using System.Threading;
using System.Threading.Tasks;
@@ -38,10 +40,10 @@ public ContractDomainEventHandler(IEstateReportingRepository estateReportingRepo
///
/// The domain event.
/// The cancellation token.
- public async Task Handle(IDomainEvent domainEvent,
- CancellationToken cancellationToken)
+ public async Task Handle(IDomainEvent domainEvent,
+ CancellationToken cancellationToken)
{
- await this.HandleSpecificDomainEvent((dynamic)domainEvent, cancellationToken);
+ return await this.HandleSpecificDomainEvent((dynamic)domainEvent, cancellationToken);
}
///
@@ -49,10 +51,10 @@ public async Task Handle(IDomainEvent domainEvent,
///
/// The domain event.
/// The cancellation token.
- private async Task HandleSpecificDomainEvent(ContractCreatedEvent domainEvent,
- CancellationToken cancellationToken)
+ private async Task HandleSpecificDomainEvent(ContractCreatedEvent domainEvent,
+ CancellationToken cancellationToken)
{
- await this.EstateReportingRepository.AddContract(domainEvent, cancellationToken);
+ return await this.EstateReportingRepository.AddContract(domainEvent, cancellationToken);
}
///
@@ -60,10 +62,10 @@ private async Task HandleSpecificDomainEvent(ContractCreatedEvent domainEvent,
///
/// The domain event.
/// The cancellation token.
- private async Task HandleSpecificDomainEvent(FixedValueProductAddedToContractEvent domainEvent,
- CancellationToken cancellationToken)
+ private async Task HandleSpecificDomainEvent(FixedValueProductAddedToContractEvent domainEvent,
+ CancellationToken cancellationToken)
{
- await this.EstateReportingRepository.AddContractProduct(domainEvent, cancellationToken);
+ return await this.EstateReportingRepository.AddContractProduct(domainEvent, cancellationToken);
}
///
@@ -71,10 +73,10 @@ private async Task HandleSpecificDomainEvent(FixedValueProductAddedToContractEve
///
/// The domain event.
/// The cancellation token.
- private async Task HandleSpecificDomainEvent(VariableValueProductAddedToContractEvent domainEvent,
- CancellationToken cancellationToken)
+ private async Task HandleSpecificDomainEvent(VariableValueProductAddedToContractEvent domainEvent,
+ CancellationToken cancellationToken)
{
- await this.EstateReportingRepository.AddContractProduct(domainEvent, cancellationToken);
+ return await this.EstateReportingRepository.AddContractProduct(domainEvent, cancellationToken);
}
///
@@ -82,10 +84,10 @@ private async Task HandleSpecificDomainEvent(VariableValueProductAddedToContract
///
/// The domain event.
/// The cancellation token.
- private async Task HandleSpecificDomainEvent(TransactionFeeForProductAddedToContractEvent domainEvent,
- CancellationToken cancellationToken)
+ private async Task HandleSpecificDomainEvent(TransactionFeeForProductAddedToContractEvent domainEvent,
+ CancellationToken cancellationToken)
{
- await this.EstateReportingRepository.AddContractProductTransactionFee(domainEvent, cancellationToken);
+ return await this.EstateReportingRepository.AddContractProductTransactionFee(domainEvent, cancellationToken);
}
///
@@ -93,10 +95,10 @@ private async Task HandleSpecificDomainEvent(TransactionFeeForProductAddedToCont
///
/// The domain event.
/// The cancellation token.
- private async Task HandleSpecificDomainEvent(TransactionFeeForProductDisabledEvent domainEvent,
- CancellationToken cancellationToken)
+ private async Task HandleSpecificDomainEvent(TransactionFeeForProductDisabledEvent domainEvent,
+ CancellationToken cancellationToken)
{
- await this.EstateReportingRepository.DisableContractProductTransactionFee(domainEvent, cancellationToken);
+ return await this.EstateReportingRepository.DisableContractProductTransactionFee(domainEvent, cancellationToken);
}
#endregion
diff --git a/EstateManagement.BusinessLogic/EventHandling/EstateDomainEventHandler.cs b/EstateManagement.BusinessLogic/EventHandling/EstateDomainEventHandler.cs
index 1cd16cc2..133ab555 100644
--- a/EstateManagement.BusinessLogic/EventHandling/EstateDomainEventHandler.cs
+++ b/EstateManagement.BusinessLogic/EventHandling/EstateDomainEventHandler.cs
@@ -1,4 +1,6 @@
-namespace EstateManagement.BusinessLogic.EventHandling;
+using SimpleResults;
+
+namespace EstateManagement.BusinessLogic.EventHandling;
using System.Threading;
using System.Threading.Tasks;
@@ -38,10 +40,10 @@ public EstateDomainEventHandler(IEstateReportingRepository estateReportingReposi
///
/// The domain event.
/// The cancellation token.
- public async Task Handle(IDomainEvent domainEvent,
- CancellationToken cancellationToken)
+ public async Task Handle(IDomainEvent domainEvent,
+ CancellationToken cancellationToken)
{
- await this.HandleSpecificDomainEvent((dynamic)domainEvent, cancellationToken);
+ return await this.HandleSpecificDomainEvent((dynamic)domainEvent, cancellationToken);
}
///
@@ -49,12 +51,14 @@ public async Task Handle(IDomainEvent domainEvent,
///
/// The domain event.
/// The cancellation token.
- private async Task HandleSpecificDomainEvent(EstateCreatedEvent domainEvent,
- CancellationToken cancellationToken)
+ private async Task HandleSpecificDomainEvent(EstateCreatedEvent domainEvent,
+ CancellationToken cancellationToken)
{
- await this.EstateReportingRepository.CreateReadModel(domainEvent, cancellationToken);
+ Result createResult = await this.EstateReportingRepository.CreateReadModel(domainEvent, cancellationToken);
+ if (createResult.IsFailed)
+ return createResult;
- await this.EstateReportingRepository.AddEstate(domainEvent, cancellationToken);
+ return await this.EstateReportingRepository.AddEstate(domainEvent, cancellationToken);
}
///
@@ -62,10 +66,10 @@ private async Task HandleSpecificDomainEvent(EstateCreatedEvent domainEvent,
///
/// The domain event.
/// The cancellation token.
- private async Task HandleSpecificDomainEvent(SecurityUserAddedToEstateEvent domainEvent,
- CancellationToken cancellationToken)
+ private async Task HandleSpecificDomainEvent(SecurityUserAddedToEstateEvent domainEvent,
+ CancellationToken cancellationToken)
{
- await this.EstateReportingRepository.AddEstateSecurityUser(domainEvent, cancellationToken);
+ return await this.EstateReportingRepository.AddEstateSecurityUser(domainEvent, cancellationToken);
}
/////
@@ -80,10 +84,10 @@ private async Task HandleSpecificDomainEvent(SecurityUserAddedToEstateEvent doma
//}
- private async Task HandleSpecificDomainEvent(EstateReferenceAllocatedEvent domainEvent,
- CancellationToken cancellationToken)
+ private async Task HandleSpecificDomainEvent(EstateReferenceAllocatedEvent domainEvent,
+ CancellationToken cancellationToken)
{
- await this.EstateReportingRepository.UpdateEstate(domainEvent, cancellationToken);
+ return await this.EstateReportingRepository.UpdateEstate(domainEvent, cancellationToken);
}
#endregion
diff --git a/EstateManagement.BusinessLogic/EventHandling/FileProcessorDomainEventHandler.cs b/EstateManagement.BusinessLogic/EventHandling/FileProcessorDomainEventHandler.cs
index 18b42cf0..2fdfc35b 100644
--- a/EstateManagement.BusinessLogic/EventHandling/FileProcessorDomainEventHandler.cs
+++ b/EstateManagement.BusinessLogic/EventHandling/FileProcessorDomainEventHandler.cs
@@ -1,4 +1,6 @@
-namespace EstateManagement.BusinessLogic.EventHandling;
+using SimpleResults;
+
+namespace EstateManagement.BusinessLogic.EventHandling;
using System.Threading;
using System.Threading.Tasks;
@@ -37,10 +39,10 @@ public FileProcessorDomainEventHandler(IEstateReportingRepository estateReportin
///
/// The domain event.
/// The cancellation token.
- public async Task Handle(IDomainEvent domainEvent,
- CancellationToken cancellationToken)
+ public async Task Handle(IDomainEvent domainEvent,
+ CancellationToken cancellationToken)
{
- await this.HandleSpecificDomainEvent((dynamic)domainEvent, cancellationToken);
+ return await this.HandleSpecificDomainEvent((dynamic)domainEvent, cancellationToken);
}
///
@@ -48,10 +50,10 @@ public async Task Handle(IDomainEvent domainEvent,
///
/// The domain event.
/// The cancellation token.
- private async Task HandleSpecificDomainEvent(ImportLogCreatedEvent domainEvent,
- CancellationToken cancellationToken)
+ private async Task HandleSpecificDomainEvent(ImportLogCreatedEvent domainEvent,
+ CancellationToken cancellationToken)
{
- await this.EstateReportingRepository.AddFileImportLog(domainEvent, cancellationToken);
+ return await this.EstateReportingRepository.AddFileImportLog(domainEvent, cancellationToken);
}
///
@@ -59,10 +61,10 @@ private async Task HandleSpecificDomainEvent(ImportLogCreatedEvent domainEvent,
///
/// The domain event.
/// The cancellation token.
- private async Task HandleSpecificDomainEvent(FileAddedToImportLogEvent domainEvent,
- CancellationToken cancellationToken)
+ private async Task HandleSpecificDomainEvent(FileAddedToImportLogEvent domainEvent,
+ CancellationToken cancellationToken)
{
- await this.EstateReportingRepository.AddFileToImportLog(domainEvent, cancellationToken);
+ return await this.EstateReportingRepository.AddFileToImportLog(domainEvent, cancellationToken);
}
///
@@ -70,10 +72,10 @@ private async Task HandleSpecificDomainEvent(FileAddedToImportLogEvent domainEve
///
/// The domain event.
/// The cancellation token.
- private async Task HandleSpecificDomainEvent(FileCreatedEvent domainEvent,
- CancellationToken cancellationToken)
+ private async Task HandleSpecificDomainEvent(FileCreatedEvent domainEvent,
+ CancellationToken cancellationToken)
{
- await this.EstateReportingRepository.AddFile(domainEvent, cancellationToken);
+ return await this.EstateReportingRepository.AddFile(domainEvent, cancellationToken);
}
///
@@ -81,10 +83,10 @@ private async Task HandleSpecificDomainEvent(FileCreatedEvent domainEvent,
///
/// The domain event.
/// The cancellation token.
- private async Task HandleSpecificDomainEvent(FileLineAddedEvent domainEvent,
- CancellationToken cancellationToken)
+ private async Task HandleSpecificDomainEvent(FileLineAddedEvent domainEvent,
+ CancellationToken cancellationToken)
{
- await this.EstateReportingRepository.AddFileLineToFile(domainEvent, cancellationToken);
+ return await this.EstateReportingRepository.AddFileLineToFile(domainEvent, cancellationToken);
}
///
@@ -92,10 +94,10 @@ private async Task HandleSpecificDomainEvent(FileLineAddedEvent domainEvent,
///
/// The domain event.
/// The cancellation token.
- private async Task HandleSpecificDomainEvent(FileLineProcessingSuccessfulEvent domainEvent,
- CancellationToken cancellationToken)
+ private async Task HandleSpecificDomainEvent(FileLineProcessingSuccessfulEvent domainEvent,
+ CancellationToken cancellationToken)
{
- await this.EstateReportingRepository.UpdateFileLine(domainEvent, cancellationToken);
+ return await this.EstateReportingRepository.UpdateFileLine(domainEvent, cancellationToken);
}
///
@@ -103,10 +105,10 @@ private async Task HandleSpecificDomainEvent(FileLineProcessingSuccessfulEvent d
///
/// The domain event.
/// The cancellation token.
- private async Task HandleSpecificDomainEvent(FileLineProcessingFailedEvent domainEvent,
- CancellationToken cancellationToken)
+ private async Task HandleSpecificDomainEvent(FileLineProcessingFailedEvent domainEvent,
+ CancellationToken cancellationToken)
{
- await this.EstateReportingRepository.UpdateFileLine(domainEvent, cancellationToken);
+ return await this.EstateReportingRepository.UpdateFileLine(domainEvent, cancellationToken);
}
///
@@ -114,10 +116,10 @@ private async Task HandleSpecificDomainEvent(FileLineProcessingFailedEvent domai
///
/// The domain event.
/// The cancellation token.
- private async Task HandleSpecificDomainEvent(FileLineProcessingIgnoredEvent domainEvent,
- CancellationToken cancellationToken)
+ private async Task HandleSpecificDomainEvent(FileLineProcessingIgnoredEvent domainEvent,
+ CancellationToken cancellationToken)
{
- await this.EstateReportingRepository.UpdateFileLine(domainEvent, cancellationToken);
+ return await this.EstateReportingRepository.UpdateFileLine(domainEvent, cancellationToken);
}
///
@@ -125,9 +127,9 @@ private async Task HandleSpecificDomainEvent(FileLineProcessingIgnoredEvent doma
///
/// The domain event.
/// The cancellation token.
- private async Task HandleSpecificDomainEvent(FileProcessingCompletedEvent domainEvent,
- CancellationToken cancellationToken)
+ private async Task HandleSpecificDomainEvent(FileProcessingCompletedEvent domainEvent,
+ CancellationToken cancellationToken)
{
- await this.EstateReportingRepository.UpdateFileAsComplete(domainEvent, cancellationToken);
+ return await this.EstateReportingRepository.UpdateFileAsComplete(domainEvent, cancellationToken);
}
}
\ No newline at end of file
diff --git a/EstateManagement.BusinessLogic/EventHandling/FloatDomainEventHandler.cs b/EstateManagement.BusinessLogic/EventHandling/FloatDomainEventHandler.cs
index 0245feb2..c38b4b90 100644
--- a/EstateManagement.BusinessLogic/EventHandling/FloatDomainEventHandler.cs
+++ b/EstateManagement.BusinessLogic/EventHandling/FloatDomainEventHandler.cs
@@ -1,4 +1,6 @@
-namespace EstateManagement.BusinessLogic.EventHandling{
+using SimpleResults;
+
+namespace EstateManagement.BusinessLogic.EventHandling{
using System.Threading;
using System.Threading.Tasks;
using Repository;
@@ -23,24 +25,24 @@ public FloatDomainEventHandler(IEstateReportingRepository estateReportingReposit
#region Methods
- public async Task Handle(IDomainEvent domainEvent,
- CancellationToken cancellationToken){
- await this.HandleSpecificDomainEvent((dynamic)domainEvent, cancellationToken);
+ public async Task Handle(IDomainEvent domainEvent,
+ CancellationToken cancellationToken){
+ return await this.HandleSpecificDomainEvent((dynamic)domainEvent, cancellationToken);
}
- private async Task HandleSpecificDomainEvent(FloatCreatedForContractProductEvent domainEvent,
- CancellationToken cancellationToken){
- await this.EstateReportingRepository.CreateFloat(domainEvent, cancellationToken);
+ private async Task HandleSpecificDomainEvent(FloatCreatedForContractProductEvent domainEvent,
+ CancellationToken cancellationToken){
+ return await this.EstateReportingRepository.CreateFloat(domainEvent, cancellationToken);
}
- private async Task HandleSpecificDomainEvent(FloatCreditPurchasedEvent domainEvent,
- CancellationToken cancellationToken){
- await this.EstateReportingRepository.CreateFloatActivity(domainEvent, cancellationToken);
+ private async Task HandleSpecificDomainEvent(FloatCreditPurchasedEvent domainEvent,
+ CancellationToken cancellationToken){
+ return await this.EstateReportingRepository.CreateFloatActivity(domainEvent, cancellationToken);
}
- private async Task HandleSpecificDomainEvent(FloatDecreasedByTransactionEvent domainEvent,
- CancellationToken cancellationToken){
- await this.EstateReportingRepository.CreateFloatActivity(domainEvent, cancellationToken);
+ private async Task HandleSpecificDomainEvent(FloatDecreasedByTransactionEvent domainEvent,
+ CancellationToken cancellationToken){
+ return await this.EstateReportingRepository.CreateFloatActivity(domainEvent, cancellationToken);
}
#endregion
diff --git a/EstateManagement.BusinessLogic/EventHandling/MerchantDomainEventHandler.cs b/EstateManagement.BusinessLogic/EventHandling/MerchantDomainEventHandler.cs
index a8456f86..81b3ecd0 100644
--- a/EstateManagement.BusinessLogic/EventHandling/MerchantDomainEventHandler.cs
+++ b/EstateManagement.BusinessLogic/EventHandling/MerchantDomainEventHandler.cs
@@ -1,4 +1,6 @@
-namespace EstateManagement.BusinessLogic.EventHandling
+using SimpleResults;
+
+namespace EstateManagement.BusinessLogic.EventHandling
{
using System;
using System.Threading;
@@ -50,10 +52,10 @@ public MerchantDomainEventHandler(IAggregateRepository Handle(IDomainEvent domainEvent,
CancellationToken cancellationToken)
{
- Task t = domainEvent switch{
+ Task t = domainEvent switch{
MerchantCreatedEvent de => this.EstateReportingRepository.AddMerchant(de, cancellationToken),
MerchantNameUpdatedEvent de => this.EstateReportingRepository.UpdateMerchant(de, cancellationToken),
AddressAddedEvent de => this.EstateReportingRepository.AddMerchantAddress(de, cancellationToken),
@@ -83,10 +85,12 @@ public async Task Handle(IDomainEvent domainEvent,
_ => null
};
if (t != null)
- await t;
+ return await t;
+
+ return Result.Success();
}
- private async Task HandleSpecificDomainEvent(CallbackReceivedEnrichedEvent domainEvent,
+ private async Task HandleSpecificDomainEvent(CallbackReceivedEnrichedEvent domainEvent,
CancellationToken cancellationToken)
{
if (domainEvent.TypeString == typeof(Deposit).ToString())
@@ -94,21 +98,24 @@ private async Task HandleSpecificDomainEvent(CallbackReceivedEnrichedEvent domai
// Work out the merchant id from the reference field (second part, split on hyphen)
String merchantReference = domainEvent.Reference.Split("-")[1];
- Merchant merchant = await this.EstateManagementRepository.GetMerchantFromReference(domainEvent.EstateId, merchantReference, cancellationToken);
+ Result result = await this.EstateManagementRepository.GetMerchantFromReference(domainEvent.EstateId, merchantReference, cancellationToken);
+ if (result.IsFailed)
+ return ResultHelpers.CreateFailure(result);
// We now need to deserialise the message from the callback
Deposit callbackMessage = JsonConvert.DeserializeObject(domainEvent.CallbackMessage);
MerchantCommands.MakeMerchantDepositCommand command = new(domainEvent.EstateId,
- merchant.MerchantId,
+ result.Data.MerchantId,
MerchantDepositSource.Automatic,
new MakeMerchantDepositRequest{
DepositDateTime = callbackMessage.DateTime,
Reference = callbackMessage.Reference,
Amount = callbackMessage.Amount,
});
- await this.Mediator.Send(command, cancellationToken);
+ return await this.Mediator.Send(command, cancellationToken);
}
+ return Result.Success();
}
diff --git a/EstateManagement.BusinessLogic/EventHandling/MerchantSettlementDomainEventHandler.cs b/EstateManagement.BusinessLogic/EventHandling/MerchantSettlementDomainEventHandler.cs
index edc2acbc..2d7c16ff 100644
--- a/EstateManagement.BusinessLogic/EventHandling/MerchantSettlementDomainEventHandler.cs
+++ b/EstateManagement.BusinessLogic/EventHandling/MerchantSettlementDomainEventHandler.cs
@@ -1,4 +1,6 @@
-namespace EstateManagement.BusinessLogic.EventHandling;
+using SimpleResults;
+
+namespace EstateManagement.BusinessLogic.EventHandling;
using System.Threading;
using System.Threading.Tasks;
@@ -20,28 +22,30 @@ public MerchantSettlementDomainEventHandler(IMediator mediator) {
this.Mediator = mediator;
}
- public async Task Handle(IDomainEvent domainEvent,
+ public async Task Handle(IDomainEvent domainEvent,
CancellationToken cancellationToken)
{
- Task t = domainEvent switch
+ Task t = domainEvent switch
{
MerchantFeeSettledEvent mfse => this.HandleSpecificDomainEvent(mfse, cancellationToken),
_ => null
};
if (t != null)
- await t;
+ return await t;
+
+ return Result.Success();
}
- private async Task HandleSpecificDomainEvent(MerchantFeeSettledEvent domainEvent,
- CancellationToken cancellationToken)
+ private async Task HandleSpecificDomainEvent(MerchantFeeSettledEvent domainEvent,
+ CancellationToken cancellationToken)
{
- AddSettledFeeToMerchantStatementRequest addSettledFeeToMerchantStatementRequest = AddSettledFeeToMerchantStatementRequest.Create(domainEvent.EstateId,
+ MerchantStatementCommands.AddSettledFeeToMerchantStatementCommand command = new(domainEvent.EstateId,
domainEvent.MerchantId,
domainEvent.FeeCalculatedDateTime,
domainEvent.CalculatedValue,
domainEvent.TransactionId,
domainEvent.FeeId);
- await this.Mediator.Send(addSettledFeeToMerchantStatementRequest, cancellationToken);
+ return await this.Mediator.Send(command, cancellationToken);
}
}
\ No newline at end of file
diff --git a/EstateManagement.BusinessLogic/EventHandling/MerchantStatementDomainEventHandler.cs b/EstateManagement.BusinessLogic/EventHandling/MerchantStatementDomainEventHandler.cs
index 18aef659..1fc383af 100644
--- a/EstateManagement.BusinessLogic/EventHandling/MerchantStatementDomainEventHandler.cs
+++ b/EstateManagement.BusinessLogic/EventHandling/MerchantStatementDomainEventHandler.cs
@@ -1,4 +1,6 @@
-namespace EstateManagement.BusinessLogic.EventHandling
+using SimpleResults;
+
+namespace EstateManagement.BusinessLogic.EventHandling
{
using System.Threading;
using System.Threading.Tasks;
@@ -40,10 +42,10 @@ public MerchantStatementDomainEventHandler(IMediator mediator)
///
/// The domain event.
/// The cancellation token.
- public async Task Handle(IDomainEvent domainEvent,
- CancellationToken cancellationToken)
+ public async Task Handle(IDomainEvent domainEvent,
+ CancellationToken cancellationToken)
{
- await this.HandleSpecificDomainEvent((dynamic)domainEvent, cancellationToken);
+ return await this.HandleSpecificDomainEvent((dynamic)domainEvent, cancellationToken);
}
///
@@ -51,26 +53,24 @@ public async Task Handle(IDomainEvent domainEvent,
///
/// The domain event.
/// The cancellation token.
- private async Task HandleSpecificDomainEvent(StatementGeneratedEvent domainEvent,
- CancellationToken cancellationToken)
- {
- EmailMerchantStatementRequest emailMerchantStatementRequest = EmailMerchantStatementRequest.Create(domainEvent.EstateId,
- domainEvent.MerchantId,
- domainEvent.MerchantStatementId);
+ private async Task HandleSpecificDomainEvent(StatementGeneratedEvent domainEvent,
+ CancellationToken cancellationToken) {
+ MerchantStatementCommands.EmailMerchantStatementCommand command = new(domainEvent.EstateId,
+ domainEvent.MerchantId, domainEvent.MerchantStatementId);
- await this.Mediator.Send(emailMerchantStatementRequest, cancellationToken);
+ return await this.Mediator.Send(command, cancellationToken);
}
- private async Task HandleSpecificDomainEvent(TransactionHasBeenCompletedEvent domainEvent,
- CancellationToken cancellationToken) {
- AddTransactionToMerchantStatementRequest addTransactionToMerchantStatementRequest = AddTransactionToMerchantStatementRequest.Create(domainEvent.EstateId,
+ private async Task HandleSpecificDomainEvent(TransactionHasBeenCompletedEvent domainEvent,
+ CancellationToken cancellationToken) {
+ MerchantStatementCommands.AddTransactionToMerchantStatementCommand command = new(domainEvent.EstateId,
domainEvent.MerchantId,
domainEvent.CompletedDateTime,
domainEvent.TransactionAmount,
domainEvent.IsAuthorised,
domainEvent.TransactionId);
- await this.Mediator.Send(addTransactionToMerchantStatementRequest, cancellationToken);
+ return await this.Mediator.Send(command, cancellationToken);
}
#endregion
diff --git a/EstateManagement.BusinessLogic/EventHandling/OperatorDomainEventHandler.cs b/EstateManagement.BusinessLogic/EventHandling/OperatorDomainEventHandler.cs
index 5653b561..d9a96f5d 100644
--- a/EstateManagement.BusinessLogic/EventHandling/OperatorDomainEventHandler.cs
+++ b/EstateManagement.BusinessLogic/EventHandling/OperatorDomainEventHandler.cs
@@ -1,4 +1,6 @@
-namespace EstateManagement.BusinessLogic.EventHandling;
+using SimpleResults;
+
+namespace EstateManagement.BusinessLogic.EventHandling;
using System.Threading;
using System.Threading.Tasks;
@@ -40,9 +42,9 @@ public OperatorDomainEventHandler(IEstateReportingRepository estateReportingRepo
///
/// The domain event.
/// The cancellation token.
- public async Task Handle(IDomainEvent domainEvent,
- CancellationToken cancellationToken){
- Task t = domainEvent switch{
+ public async Task Handle(IDomainEvent domainEvent,
+ CancellationToken cancellationToken){
+ Task t = domainEvent switch{
OperatorCreatedEvent oce => this.EstateReportingRepository.AddOperator(oce, cancellationToken),
OperatorNameUpdatedEvent onue => this.EstateReportingRepository.UpdateOperator(onue, cancellationToken),
OperatorRequireCustomMerchantNumberChangedEvent oprcmnce => this.EstateReportingRepository.UpdateOperator(oprcmnce, cancellationToken),
@@ -50,7 +52,9 @@ public async Task Handle(IDomainEvent domainEvent,
_ => null
};
if (t != null)
- await t;
+ return await t;
+
+ return Result.Success();
}
#endregion
diff --git a/EstateManagement.BusinessLogic/EventHandling/SettlementDomainEventHandler.cs b/EstateManagement.BusinessLogic/EventHandling/SettlementDomainEventHandler.cs
index 10c16c81..c26a8755 100644
--- a/EstateManagement.BusinessLogic/EventHandling/SettlementDomainEventHandler.cs
+++ b/EstateManagement.BusinessLogic/EventHandling/SettlementDomainEventHandler.cs
@@ -1,4 +1,6 @@
-namespace EstateManagement.BusinessLogic.EventHandling
+using SimpleResults;
+
+namespace EstateManagement.BusinessLogic.EventHandling
{
using System.Threading;
using System.Threading.Tasks;
@@ -40,10 +42,10 @@ public SettlementDomainEventHandler(IEstateReportingRepository estateReportingRe
///
/// The domain event.
/// The cancellation token.
- public async Task Handle(IDomainEvent domainEvent,
- CancellationToken cancellationToken)
+ public async Task Handle(IDomainEvent domainEvent,
+ CancellationToken cancellationToken)
{
- await this.HandleSpecificDomainEvent((dynamic)domainEvent, cancellationToken);
+ return await this.HandleSpecificDomainEvent((dynamic)domainEvent, cancellationToken);
}
///
@@ -51,40 +53,40 @@ public async Task Handle(IDomainEvent domainEvent,
///
/// The domain event.
/// The cancellation token.
- private async Task HandleSpecificDomainEvent(MerchantFeeSettledEvent domainEvent,
+ private async Task HandleSpecificDomainEvent(MerchantFeeSettledEvent domainEvent,
CancellationToken cancellationToken)
{
- await this.EstateReportingRepository.MarkMerchantFeeAsSettled(domainEvent, cancellationToken);
+ return await this.EstateReportingRepository.MarkMerchantFeeAsSettled(domainEvent, cancellationToken);
}
- private async Task HandleSpecificDomainEvent(SettlementProcessingStartedEvent domainEvent,
+ private async Task HandleSpecificDomainEvent(SettlementProcessingStartedEvent domainEvent,
CancellationToken cancellationToken)
{
- await this.EstateReportingRepository.MarkSettlementAsProcessingStarted(domainEvent, cancellationToken);
+ return await this.EstateReportingRepository.MarkSettlementAsProcessingStarted(domainEvent, cancellationToken);
}
- private async Task HandleSpecificDomainEvent(SettlementCreatedForDateEvent domainEvent,
+ private async Task HandleSpecificDomainEvent(SettlementCreatedForDateEvent domainEvent,
CancellationToken cancellationToken)
{
- await this.EstateReportingRepository.CreateSettlement(domainEvent, cancellationToken);
+ return await this.EstateReportingRepository.CreateSettlement(domainEvent, cancellationToken);
}
- private async Task HandleSpecificDomainEvent(SettledMerchantFeeAddedToTransactionEvent domainEvent,
- CancellationToken cancellationToken)
+ private async Task HandleSpecificDomainEvent(SettledMerchantFeeAddedToTransactionEvent domainEvent,
+ CancellationToken cancellationToken)
{
- await this.EstateReportingRepository.AddSettledMerchantFeeToSettlement(domainEvent, cancellationToken);
+ return await this.EstateReportingRepository.AddSettledMerchantFeeToSettlement(domainEvent, cancellationToken);
}
- private async Task HandleSpecificDomainEvent(MerchantFeeAddedPendingSettlementEvent domainEvent,
- CancellationToken cancellationToken)
+ private async Task HandleSpecificDomainEvent(MerchantFeeAddedPendingSettlementEvent domainEvent,
+ CancellationToken cancellationToken)
{
- await this.EstateReportingRepository.AddPendingMerchantFeeToSettlement(domainEvent, cancellationToken);
+ return await this.EstateReportingRepository.AddPendingMerchantFeeToSettlement(domainEvent, cancellationToken);
}
- private async Task HandleSpecificDomainEvent(SettlementCompletedEvent domainEvent,
- CancellationToken cancellationToken)
+ private async Task HandleSpecificDomainEvent(SettlementCompletedEvent domainEvent,
+ CancellationToken cancellationToken)
{
- await this.EstateReportingRepository.MarkSettlementAsCompleted(domainEvent, cancellationToken);
+ return await this.EstateReportingRepository.MarkSettlementAsCompleted(domainEvent, cancellationToken);
}
#endregion
diff --git a/EstateManagement.BusinessLogic/EventHandling/StatementDomainEventHandler.cs b/EstateManagement.BusinessLogic/EventHandling/StatementDomainEventHandler.cs
index 5dcd4826..956e5d44 100644
--- a/EstateManagement.BusinessLogic/EventHandling/StatementDomainEventHandler.cs
+++ b/EstateManagement.BusinessLogic/EventHandling/StatementDomainEventHandler.cs
@@ -1,4 +1,6 @@
-namespace EstateManagement.BusinessLogic.EventHandling
+using SimpleResults;
+
+namespace EstateManagement.BusinessLogic.EventHandling
{
using System.Threading;
using System.Threading.Tasks;
@@ -33,34 +35,34 @@ public StatementDomainEventHandler(IEstateReportingRepository estateReportingRep
#region Methods
- public async Task Handle(IDomainEvent domainEvent,
- CancellationToken cancellationToken)
+ public async Task Handle(IDomainEvent domainEvent,
+ CancellationToken cancellationToken)
{
- await this.HandleSpecificDomainEvent((dynamic)domainEvent, cancellationToken);
+ return await this.HandleSpecificDomainEvent((dynamic)domainEvent, cancellationToken);
}
- private async Task HandleSpecificDomainEvent(StatementCreatedEvent domainEvent,
- CancellationToken cancellationToken)
+ private async Task HandleSpecificDomainEvent(StatementCreatedEvent domainEvent,
+ CancellationToken cancellationToken)
{
- await this.EstateReportingRepository.CreateStatement(domainEvent, cancellationToken);
+ return await this.EstateReportingRepository.CreateStatement(domainEvent, cancellationToken);
}
- private async Task HandleSpecificDomainEvent(TransactionAddedToStatementEvent domainEvent,
- CancellationToken cancellationToken)
+ private async Task HandleSpecificDomainEvent(TransactionAddedToStatementEvent domainEvent,
+ CancellationToken cancellationToken)
{
- await this.EstateReportingRepository.AddTransactionToStatement(domainEvent, cancellationToken);
+ return await this.EstateReportingRepository.AddTransactionToStatement(domainEvent, cancellationToken);
}
- private async Task HandleSpecificDomainEvent(SettledFeeAddedToStatementEvent domainEvent,
- CancellationToken cancellationToken)
+ private async Task HandleSpecificDomainEvent(SettledFeeAddedToStatementEvent domainEvent,
+ CancellationToken cancellationToken)
{
- await this.EstateReportingRepository.AddSettledFeeToStatement(domainEvent, cancellationToken);
+ return await this.EstateReportingRepository.AddSettledFeeToStatement(domainEvent, cancellationToken);
}
- private async Task HandleSpecificDomainEvent(StatementGeneratedEvent domainEvent,
- CancellationToken cancellationToken)
+ private async Task HandleSpecificDomainEvent(StatementGeneratedEvent domainEvent,
+ CancellationToken cancellationToken)
{
- await this.EstateReportingRepository.MarkStatementAsGenerated(domainEvent, cancellationToken);
+ return await this.EstateReportingRepository.MarkStatementAsGenerated(domainEvent, cancellationToken);
}
#endregion
}
diff --git a/EstateManagement.BusinessLogic/EventHandling/TransactionDomainEventHandler.cs b/EstateManagement.BusinessLogic/EventHandling/TransactionDomainEventHandler.cs
index 15351317..099e2d53 100644
--- a/EstateManagement.BusinessLogic/EventHandling/TransactionDomainEventHandler.cs
+++ b/EstateManagement.BusinessLogic/EventHandling/TransactionDomainEventHandler.cs
@@ -1,4 +1,6 @@
-namespace EstateManagement.BusinessLogic.EventHandling
+using SimpleResults;
+
+namespace EstateManagement.BusinessLogic.EventHandling
{
using System;
using System.Diagnostics.CodeAnalysis;
@@ -50,10 +52,10 @@ public TransactionDomainEventHandler(IMediator mediator, IEstateReportingReposit
///
/// The domain event.
/// The cancellation token.
- public async Task Handle(IDomainEvent domainEvent,
- CancellationToken cancellationToken)
+ public async Task Handle(IDomainEvent domainEvent,
+ CancellationToken cancellationToken)
{
- await this.HandleSpecificDomainEvent((dynamic)domainEvent, cancellationToken);
+ return await this.HandleSpecificDomainEvent((dynamic)domainEvent, cancellationToken);
}
///
@@ -61,10 +63,10 @@ public async Task Handle(IDomainEvent domainEvent,
///
/// The domain event.
/// The cancellation token.
- private async Task HandleSpecificDomainEvent(TransactionHasBeenCompletedEvent domainEvent,
- CancellationToken cancellationToken)
+ private async Task HandleSpecificDomainEvent(TransactionHasBeenCompletedEvent domainEvent,
+ CancellationToken cancellationToken)
{
- await this.EstateReportingRepository.CompleteTransaction(domainEvent, cancellationToken);
+ return await this.EstateReportingRepository.CompleteTransaction(domainEvent, cancellationToken);
}
///
@@ -75,10 +77,10 @@ private async Task HandleSpecificDomainEvent(TransactionHasBeenCompletedEvent do
[ExcludeFromCodeCoverage]
internal static String HexStringFromBytes(Byte[] bytes)
{
- var sb = new StringBuilder();
+ StringBuilder sb = new StringBuilder();
foreach (Byte b in bytes)
{
- var hex = b.ToString("x2");
+ String hex = b.ToString("x2");
sb.Append(hex);
}
@@ -90,10 +92,10 @@ internal static String HexStringFromBytes(Byte[] bytes)
///
/// The domain event.
/// The cancellation token.
- private async Task HandleSpecificDomainEvent(TransactionHasStartedEvent domainEvent,
- CancellationToken cancellationToken)
+ private async Task HandleSpecificDomainEvent(TransactionHasStartedEvent domainEvent,
+ CancellationToken cancellationToken)
{
- await this.EstateReportingRepository.StartTransaction(domainEvent, cancellationToken);
+ return await this.EstateReportingRepository.StartTransaction(domainEvent, cancellationToken);
}
///
@@ -101,11 +103,13 @@ private async Task HandleSpecificDomainEvent(TransactionHasStartedEvent domainEv
///
/// The domain event.
/// The cancellation token.
- private async Task HandleSpecificDomainEvent(AdditionalRequestDataRecordedEvent domainEvent,
- CancellationToken cancellationToken)
+ private async Task HandleSpecificDomainEvent(AdditionalRequestDataRecordedEvent domainEvent,
+ CancellationToken cancellationToken)
{
- await this.EstateReportingRepository.RecordTransactionAdditionalRequestData(domainEvent, cancellationToken);
- await this.EstateReportingRepository.SetTransactionAmount(domainEvent, cancellationToken);
+ var result = await this.EstateReportingRepository.RecordTransactionAdditionalRequestData(domainEvent, cancellationToken);
+ if (result.IsFailed)
+ return result;
+ return await this.EstateReportingRepository.SetTransactionAmount(domainEvent, cancellationToken);
}
///
@@ -113,10 +117,10 @@ private async Task HandleSpecificDomainEvent(AdditionalRequestDataRecordedEvent
///
/// The domain event.
/// The cancellation token.
- private async Task HandleSpecificDomainEvent(AdditionalResponseDataRecordedEvent domainEvent,
- CancellationToken cancellationToken)
+ private async Task HandleSpecificDomainEvent(AdditionalResponseDataRecordedEvent domainEvent,
+ CancellationToken cancellationToken)
{
- await this.EstateReportingRepository.RecordTransactionAdditionalResponseData(domainEvent, cancellationToken);
+ return await this.EstateReportingRepository.RecordTransactionAdditionalResponseData(domainEvent, cancellationToken);
}
///
@@ -124,10 +128,10 @@ private async Task HandleSpecificDomainEvent(AdditionalResponseDataRecordedEvent
///
/// The domain event.
/// The cancellation token.
- private async Task HandleSpecificDomainEvent(TransactionHasBeenLocallyAuthorisedEvent domainEvent,
- CancellationToken cancellationToken)
+ private async Task HandleSpecificDomainEvent(TransactionHasBeenLocallyAuthorisedEvent domainEvent,
+ CancellationToken cancellationToken)
{
- await this.EstateReportingRepository.UpdateTransactionAuthorisation(domainEvent, cancellationToken);
+ return await this.EstateReportingRepository.UpdateTransactionAuthorisation(domainEvent, cancellationToken);
}
///
@@ -135,10 +139,10 @@ private async Task HandleSpecificDomainEvent(TransactionHasBeenLocallyAuthorised
///
/// The domain event.
/// The cancellation token.
- private async Task HandleSpecificDomainEvent(TransactionHasBeenLocallyDeclinedEvent domainEvent,
- CancellationToken cancellationToken)
+ private async Task HandleSpecificDomainEvent(TransactionHasBeenLocallyDeclinedEvent domainEvent,
+ CancellationToken cancellationToken)
{
- await this.EstateReportingRepository.UpdateTransactionAuthorisation(domainEvent, cancellationToken);
+ return await this.EstateReportingRepository.UpdateTransactionAuthorisation(domainEvent, cancellationToken);
}
///
@@ -146,10 +150,10 @@ private async Task HandleSpecificDomainEvent(TransactionHasBeenLocallyDeclinedEv
///
/// The domain event.
/// The cancellation token.
- private async Task HandleSpecificDomainEvent(TransactionAuthorisedByOperatorEvent domainEvent,
- CancellationToken cancellationToken)
+ private async Task HandleSpecificDomainEvent(TransactionAuthorisedByOperatorEvent domainEvent,
+ CancellationToken cancellationToken)
{
- await this.EstateReportingRepository.UpdateTransactionAuthorisation(domainEvent, cancellationToken);
+ return await this.EstateReportingRepository.UpdateTransactionAuthorisation(domainEvent, cancellationToken);
}
///
@@ -157,16 +161,16 @@ private async Task HandleSpecificDomainEvent(TransactionAuthorisedByOperatorEven
///
/// The domain event.
/// The cancellation token.
- private async Task HandleSpecificDomainEvent(TransactionDeclinedByOperatorEvent domainEvent,
- CancellationToken cancellationToken)
+ private async Task HandleSpecificDomainEvent(TransactionDeclinedByOperatorEvent domainEvent,
+ CancellationToken cancellationToken)
{
- await this.EstateReportingRepository.UpdateTransactionAuthorisation(domainEvent, cancellationToken);
+ return await this.EstateReportingRepository.UpdateTransactionAuthorisation(domainEvent, cancellationToken);
}
- private async Task HandleSpecificDomainEvent(TransactionSourceAddedToTransactionEvent domainEvent,
+ private async Task HandleSpecificDomainEvent(TransactionSourceAddedToTransactionEvent domainEvent,
CancellationToken cancellationToken)
{
- await this.EstateReportingRepository.AddSourceDetailsToTransaction(domainEvent, cancellationToken);
+ return await this.EstateReportingRepository.AddSourceDetailsToTransaction(domainEvent, cancellationToken);
}
///
@@ -174,10 +178,10 @@ private async Task HandleSpecificDomainEvent(TransactionSourceAddedToTransaction
///
/// The domain event.
/// The cancellation token.
- private async Task HandleSpecificDomainEvent(ProductDetailsAddedToTransactionEvent domainEvent,
- CancellationToken cancellationToken)
+ private async Task HandleSpecificDomainEvent(ProductDetailsAddedToTransactionEvent domainEvent,
+ CancellationToken cancellationToken)
{
- await this.EstateReportingRepository.AddProductDetailsToTransaction(domainEvent, cancellationToken);
+ return await this.EstateReportingRepository.AddProductDetailsToTransaction(domainEvent, cancellationToken);
}
///
@@ -185,10 +189,10 @@ private async Task HandleSpecificDomainEvent(ProductDetailsAddedToTransactionEve
///
/// The domain event.
/// The cancellation token.
- private async Task HandleSpecificDomainEvent(ReconciliationHasStartedEvent domainEvent,
- CancellationToken cancellationToken)
+ private async Task HandleSpecificDomainEvent(ReconciliationHasStartedEvent domainEvent,
+ CancellationToken cancellationToken)
{
- await this.EstateReportingRepository.StartReconciliation(domainEvent, cancellationToken);
+ return await this.EstateReportingRepository.StartReconciliation(domainEvent, cancellationToken);
}
///
@@ -196,10 +200,10 @@ private async Task HandleSpecificDomainEvent(ReconciliationHasStartedEvent domai
///
/// The domain event.
/// The cancellation token.
- private async Task HandleSpecificDomainEvent(OverallTotalsRecordedEvent domainEvent,
- CancellationToken cancellationToken)
+ private async Task HandleSpecificDomainEvent(OverallTotalsRecordedEvent domainEvent,
+ CancellationToken cancellationToken)
{
- await this.EstateReportingRepository.UpdateReconciliationOverallTotals(domainEvent, cancellationToken);
+ return await this.EstateReportingRepository.UpdateReconciliationOverallTotals(domainEvent, cancellationToken);
}
///
@@ -207,10 +211,10 @@ private async Task HandleSpecificDomainEvent(OverallTotalsRecordedEvent domainEv
///
/// The domain event.
/// The cancellation token.
- private async Task HandleSpecificDomainEvent(ReconciliationHasBeenLocallyAuthorisedEvent domainEvent,
- CancellationToken cancellationToken)
+ private async Task HandleSpecificDomainEvent(ReconciliationHasBeenLocallyAuthorisedEvent domainEvent,
+ CancellationToken cancellationToken)
{
- await this.EstateReportingRepository.UpdateReconciliationStatus(domainEvent, cancellationToken);
+ return await this.EstateReportingRepository.UpdateReconciliationStatus(domainEvent, cancellationToken);
}
///
@@ -218,10 +222,10 @@ private async Task HandleSpecificDomainEvent(ReconciliationHasBeenLocallyAuthori
///
/// The domain event.
/// The cancellation token.
- private async Task HandleSpecificDomainEvent(ReconciliationHasBeenLocallyDeclinedEvent domainEvent,
- CancellationToken cancellationToken)
+ private async Task HandleSpecificDomainEvent(ReconciliationHasBeenLocallyDeclinedEvent domainEvent,
+ CancellationToken cancellationToken)
{
- await this.EstateReportingRepository.UpdateReconciliationStatus(domainEvent, cancellationToken);
+ return await this.EstateReportingRepository.UpdateReconciliationStatus(domainEvent, cancellationToken);
}
///
@@ -229,10 +233,10 @@ private async Task HandleSpecificDomainEvent(ReconciliationHasBeenLocallyDecline
///
/// The domain event.
/// The cancellation token.
- private async Task HandleSpecificDomainEvent(ReconciliationHasCompletedEvent domainEvent,
- CancellationToken cancellationToken)
+ private async Task HandleSpecificDomainEvent(ReconciliationHasCompletedEvent domainEvent,
+ CancellationToken cancellationToken)
{
- await this.EstateReportingRepository.CompleteReconciliation(domainEvent, cancellationToken);
+ return await this.EstateReportingRepository.CompleteReconciliation(domainEvent, cancellationToken);
}
///
@@ -240,10 +244,10 @@ private async Task HandleSpecificDomainEvent(ReconciliationHasCompletedEvent dom
///
/// The domain event.
/// The cancellation token.
- private async Task HandleSpecificDomainEvent(VoucherGeneratedEvent domainEvent,
- CancellationToken cancellationToken)
+ private async Task HandleSpecificDomainEvent(VoucherGeneratedEvent domainEvent,
+ CancellationToken cancellationToken)
{
- await this.EstateReportingRepository.AddGeneratedVoucher(domainEvent, cancellationToken);
+ return await this.EstateReportingRepository.AddGeneratedVoucher(domainEvent, cancellationToken);
}
///
@@ -251,10 +255,10 @@ private async Task HandleSpecificDomainEvent(VoucherGeneratedEvent domainEvent,
///
/// The domain event.
/// The cancellation token.
- private async Task HandleSpecificDomainEvent(VoucherIssuedEvent domainEvent,
- CancellationToken cancellationToken)
+ private async Task HandleSpecificDomainEvent(VoucherIssuedEvent domainEvent,
+ CancellationToken cancellationToken)
{
- await this.EstateReportingRepository.UpdateVoucherIssueDetails(domainEvent, cancellationToken);
+ return await this.EstateReportingRepository.UpdateVoucherIssueDetails(domainEvent, cancellationToken);
}
///
@@ -262,10 +266,10 @@ private async Task HandleSpecificDomainEvent(VoucherIssuedEvent domainEvent,
///
/// The domain event.
/// The cancellation token.
- private async Task HandleSpecificDomainEvent(VoucherFullyRedeemedEvent domainEvent,
- CancellationToken cancellationToken)
+ private async Task HandleSpecificDomainEvent(VoucherFullyRedeemedEvent domainEvent,
+ CancellationToken cancellationToken)
{
- await this.EstateReportingRepository.UpdateVoucherRedemptionDetails(domainEvent, cancellationToken);
+ return await this.EstateReportingRepository.UpdateVoucherRedemptionDetails(domainEvent, cancellationToken);
}
#endregion
diff --git a/EstateManagement.BusinessLogic/RequestHandlers/MerchantStatementRequestHandler.cs b/EstateManagement.BusinessLogic/RequestHandlers/MerchantStatementRequestHandler.cs
index fffde507..01620b6c 100644
--- a/EstateManagement.BusinessLogic/RequestHandlers/MerchantStatementRequestHandler.cs
+++ b/EstateManagement.BusinessLogic/RequestHandlers/MerchantStatementRequestHandler.cs
@@ -15,10 +15,10 @@
///
///
///
- public class MerchantStatementRequestHandler : IRequestHandler,
- IRequestHandler,
+ public class MerchantStatementRequestHandler : IRequestHandler,
+ IRequestHandler,
IRequestHandler,
- IRequestHandler
+ IRequestHandler
{
#region Fields
@@ -50,10 +50,10 @@ public MerchantStatementRequestHandler(IMerchantStatementDomainService merchantS
/// The request.
/// The cancellation token.
///
- public async Task Handle(AddTransactionToMerchantStatementRequest command,
- CancellationToken cancellationToken)
+ public async Task Handle(MerchantStatementCommands.AddTransactionToMerchantStatementCommand command,
+ CancellationToken cancellationToken)
{
- await this.MerchantStatementDomainService.AddTransactionToStatement(command,
+ return await this.MerchantStatementDomainService.AddTransactionToStatement(command,
cancellationToken);
}
@@ -63,10 +63,10 @@ await this.MerchantStatementDomainService.AddTransactionToStatement(command,
/// The request.
/// The cancellation token.
///
- public async Task Handle(AddSettledFeeToMerchantStatementRequest command,
- CancellationToken cancellationToken)
+ public async Task Handle(MerchantStatementCommands.AddSettledFeeToMerchantStatementCommand command,
+ CancellationToken cancellationToken)
{
- await this.MerchantStatementDomainService.AddSettledFeeToStatement(command,
+ return await this.MerchantStatementDomainService.AddSettledFeeToStatement(command,
cancellationToken);
}
@@ -77,10 +77,10 @@ public async Task Handle(MerchantCommands.GenerateMerchantStatementComma
return await this.MerchantStatementDomainService.GenerateStatement(command, cancellationToken);
}
- public async Task Handle(EmailMerchantStatementRequest command,
- CancellationToken cancellationToken)
+ public async Task Handle(MerchantStatementCommands.EmailMerchantStatementCommand command,
+ CancellationToken cancellationToken)
{
- await this.MerchantStatementDomainService.EmailStatement(command, cancellationToken);
+ return await this.MerchantStatementDomainService.EmailStatement(command, cancellationToken);
}
}
}
\ No newline at end of file
diff --git a/EstateManagement.BusinessLogic/Requests/AddSettledFeeToMerchantStatementRequest.cs b/EstateManagement.BusinessLogic/Requests/AddSettledFeeToMerchantStatementRequest.cs
deleted file mode 100644
index b55529fd..00000000
--- a/EstateManagement.BusinessLogic/Requests/AddSettledFeeToMerchantStatementRequest.cs
+++ /dev/null
@@ -1,113 +0,0 @@
-namespace EstateManagement.BusinessLogic.Requests
-{
- using System;
- using MediatR;
-
- public class AddSettledFeeToMerchantStatementRequest : IRequest
- {
- #region Constructors
-
- ///
- /// Initializes a new instance of the class.
- ///
- /// The estate identifier.
- /// The merchant identifier.
- /// The settled date time.
- /// The settled amount.
- /// The transaction identifier.
- /// The settled fee identifier.
- private AddSettledFeeToMerchantStatementRequest(Guid estateId,
- Guid merchantId,
- DateTime settledDateTime,
- Decimal settledAmount,
- Guid transactionId,
- Guid settledFeeId)
- {
- this.EstateId = estateId;
- this.MerchantId = merchantId;
- this.SettledDateTime = settledDateTime;
- this.SettledAmount = settledAmount;
- this.TransactionId = transactionId;
- this.SettledFeeId = settledFeeId;
- }
-
- #endregion
-
- #region Properties
-
- ///
- /// Gets the settled fee identifier.
- ///
- ///
- /// The settled fee identifier.
- ///
- public Guid SettledFeeId { get; }
- ///
- /// Gets the transaction identifier.
- ///
- ///
- /// The transaction identifier.
- ///
- public Guid TransactionId { get; }
-
- ///
- /// Gets the settled date time.
- ///
- ///
- /// The settled date time.
- ///
- public DateTime SettledDateTime { get; }
-
- ///
- /// Gets the settled amount.
- ///
- ///
- /// The settled amount.
- ///
- public Decimal SettledAmount { get; }
-
- ///
- /// Gets the estate identifier.
- ///
- ///
- /// The estate identifier.
- ///
- public Guid EstateId { get; }
-
- ///
- /// Gets the merchant identifier.
- ///
- ///
- /// The merchant identifier.
- ///
- public Guid MerchantId { get; }
-
- #endregion
-
- #region Methods
-
-
- ///
- /// Creates the specified merchant statement identifier.
- ///
- /// The estate identifier.
- /// The merchant identifier.
- /// The settled date time.
- /// The settled amount.
- /// The transaction identifier.
- /// The settled fee identifier.
- ///
- public static AddSettledFeeToMerchantStatementRequest Create(Guid estateId,
- Guid merchantId,
- DateTime settledDateTime,
- Decimal settledAmount,
- Guid transactionId,
- Guid settledFeeId)
- {
- return new AddSettledFeeToMerchantStatementRequest(estateId, merchantId, settledDateTime,settledAmount,transactionId,settledFeeId);
- }
-
- #endregion
-
- }
-}
\ No newline at end of file
diff --git a/EstateManagement.BusinessLogic/Requests/AddTransactionToMerchantStatementRequest.cs b/EstateManagement.BusinessLogic/Requests/AddTransactionToMerchantStatementRequest.cs
deleted file mode 100644
index f962549f..00000000
--- a/EstateManagement.BusinessLogic/Requests/AddTransactionToMerchantStatementRequest.cs
+++ /dev/null
@@ -1,78 +0,0 @@
-namespace EstateManagement.BusinessLogic.Requests
-{
- using System;
- using MediatR;
-
- public class AddTransactionToMerchantStatementRequest : IRequest
- {
- #region Constructors
-
- ///
- /// Initializes a new instance of the class.
- ///
- /// The estate identifier.
- /// The merchant identifier.
- /// The transaction date time.
- /// The transaction amount.
- /// if set to true [is authorised].
- /// The transaction identifier.
- private AddTransactionToMerchantStatementRequest(Guid estateId,
- Guid merchantId,
- DateTime transactionDateTime,
- Decimal? transactionAmount,
- Boolean isAuthorised,
- Guid transactionId)
- {
- this.EstateId = estateId;
- this.MerchantId = merchantId;
- this.TransactionDateTime = transactionDateTime;
- this.TransactionAmount = transactionAmount;
- this.TransactionId = transactionId;
- this.IsAuthorised = isAuthorised;
- }
-
- #endregion
-
- #region Properties
-
- public Guid TransactionId { get; }
-
- public DateTime TransactionDateTime { get; }
-
- public Decimal? TransactionAmount { get; }
-
- public Boolean IsAuthorised { get; }
-
- public Guid EstateId { get; }
-
- public Guid MerchantId { get; }
-
- #endregion
-
- #region Methods
-
-
- ///
- /// Creates the specified merchant statement identifier.
- ///
- /// The estate identifier.
- /// The merchant identifier.
- /// The transaction date time.
- /// The transaction amount.
- /// if set to true [is authorised].
- /// The transaction identifier.
- ///
- public static AddTransactionToMerchantStatementRequest Create(Guid estateId,
- Guid merchantId,
- DateTime transactionDateTime,
- Decimal? transactionAmount,
- Boolean isAuthorised,
- Guid transactionId)
- {
- return new AddTransactionToMerchantStatementRequest(estateId, merchantId, transactionDateTime, transactionAmount, isAuthorised, transactionId);
- }
-
- #endregion
-
- }
-}
\ No newline at end of file
diff --git a/EstateManagement.BusinessLogic/Requests/EmailMerchantStatementRequest.cs b/EstateManagement.BusinessLogic/Requests/EmailMerchantStatementRequest.cs
deleted file mode 100644
index 215d074a..00000000
--- a/EstateManagement.BusinessLogic/Requests/EmailMerchantStatementRequest.cs
+++ /dev/null
@@ -1,62 +0,0 @@
-using System;
-
-namespace EstateManagement.BusinessLogic.Requests
-{
- using MediatR;
-
- public class EmailMerchantStatementRequest : IRequest
- {
- #region Constructors
-
- ///
- /// Initializes a new instance of the class.
- ///
- /// The estate identifier.
- /// The merchant identifier.
- /// The merchant statement identifier.
- private EmailMerchantStatementRequest(Guid estateId,
- Guid merchantId,
- Guid merchantStatementId)
- {
- this.EstateId = estateId;
- this.MerchantId = merchantId;
- this.MerchantStatementId = merchantStatementId;
- }
-
- #endregion
-
- #region Properties
-
- public Guid MerchantStatementId { get; }
-
- ///
- /// The estate identifier
- ///
- public Guid EstateId { get; }
-
- ///
- /// The merchant identifier
- ///
- public Guid MerchantId { get; }
-
- #endregion
-
- #region Methods
-
- ///
- /// Creates the specified estate identifier.
- ///
- /// The estate identifier.
- /// The merchant identifier.
- /// The merchant statement identifier.
- ///
- public static EmailMerchantStatementRequest Create(Guid estateId,
- Guid merchantId,
- Guid merchantStatementId)
- {
- return new EmailMerchantStatementRequest(estateId, merchantId, merchantStatementId);
- }
-
- #endregion
- }
-}
diff --git a/EstateManagement.BusinessLogic/Requests/MerchantStatementCommands.cs b/EstateManagement.BusinessLogic/Requests/MerchantStatementCommands.cs
new file mode 100644
index 00000000..195cef34
--- /dev/null
+++ b/EstateManagement.BusinessLogic/Requests/MerchantStatementCommands.cs
@@ -0,0 +1,25 @@
+using System;
+using MediatR;
+using SimpleResults;
+
+namespace EstateManagement.BusinessLogic.Requests;
+
+public record MerchantStatementCommands {
+ public record AddTransactionToMerchantStatementCommand(Guid EstateId,
+ Guid MerchantId,
+ DateTime TransactionDateTime,
+ Decimal? TransactionAmount,
+ Boolean IsAuthorised,
+ Guid TransactionId) : IRequest;
+
+ public record EmailMerchantStatementCommand(Guid EstateId,
+ Guid MerchantId,
+ Guid MerchantStatementId) : IRequest;
+
+ public record AddSettledFeeToMerchantStatementCommand(Guid EstateId,
+ Guid MerchantId,
+ DateTime SettledDateTime,
+ Decimal SettledAmount,
+ Guid TransactionId,
+ Guid SettledFeeId) : IRequest;
+}
\ No newline at end of file
diff --git a/EstateManagement.BusinessLogic/Services/IMerchantStatementDomainService.cs b/EstateManagement.BusinessLogic/Services/IMerchantStatementDomainService.cs
index 6e1d57da..aa20b0fb 100644
--- a/EstateManagement.BusinessLogic/Services/IMerchantStatementDomainService.cs
+++ b/EstateManagement.BusinessLogic/Services/IMerchantStatementDomainService.cs
@@ -14,13 +14,13 @@ public interface IMerchantStatementDomainService
{
#region Methods
- Task AddTransactionToStatement(AddTransactionToMerchantStatementRequest command, CancellationToken cancellationToken);
+ Task AddTransactionToStatement(MerchantStatementCommands.AddTransactionToMerchantStatementCommand command, CancellationToken cancellationToken);
- Task AddSettledFeeToStatement(AddSettledFeeToMerchantStatementRequest command, CancellationToken cancellationToken);
+ Task AddSettledFeeToStatement(MerchantStatementCommands.AddSettledFeeToMerchantStatementCommand command, CancellationToken cancellationToken);
Task GenerateStatement(MerchantCommands.GenerateMerchantStatementCommand command, CancellationToken cancellationToken);
- Task EmailStatement(EmailMerchantStatementRequest command, CancellationToken cancellationToken);
+ Task EmailStatement(MerchantStatementCommands.EmailMerchantStatementCommand command, CancellationToken cancellationToken);
#endregion
}
diff --git a/EstateManagement.BusinessLogic/Services/MerchantStatementDomainService.cs b/EstateManagement.BusinessLogic/Services/MerchantStatementDomainService.cs
index 227cea14..c69dfa44 100644
--- a/EstateManagement.BusinessLogic/Services/MerchantStatementDomainService.cs
+++ b/EstateManagement.BusinessLogic/Services/MerchantStatementDomainService.cs
@@ -142,7 +142,7 @@ private async Task> GetLatestVersion(Guid sta
return merchantStatementAggregate;
}
- public async Task AddSettledFeeToStatement(AddSettledFeeToMerchantStatementRequest command,
+ public async Task AddSettledFeeToStatement(MerchantStatementCommands.AddSettledFeeToMerchantStatementCommand command,
CancellationToken cancellationToken)
{
// Work out the next statement date
@@ -221,7 +221,7 @@ public async Task GenerateStatement(MerchantCommands.GenerateMerchantSta
return Result.Success();
}
- public async Task EmailStatement(EmailMerchantStatementRequest command,
+ public async Task EmailStatement(MerchantStatementCommands.EmailMerchantStatementCommand command,
CancellationToken cancellationToken)
{
Result result = await ApplyUpdates(
@@ -277,7 +277,7 @@ public async Task EmailStatement(EmailMerchantStatementRequest command,
///
private TokenResponse TokenResponse;
- public async Task AddTransactionToStatement(AddTransactionToMerchantStatementRequest command,
+ public async Task AddTransactionToStatement(MerchantStatementCommands.AddTransactionToMerchantStatementCommand command,
CancellationToken cancellationToken)
{
// Transaction Completed arrives(if this is a logon transaction or failed then return)
diff --git a/EstateManagement.Client/EstateManagement.Client.csproj b/EstateManagement.Client/EstateManagement.Client.csproj
index 236f89b4..0dc6bf08 100644
--- a/EstateManagement.Client/EstateManagement.Client.csproj
+++ b/EstateManagement.Client/EstateManagement.Client.csproj
@@ -7,7 +7,7 @@
-
+
diff --git a/EstateManagement.Contract.DomainEvents/EstateManagement.Contract.DomainEvents.csproj b/EstateManagement.Contract.DomainEvents/EstateManagement.Contract.DomainEvents.csproj
index c8f0eda9..ecba1956 100644
--- a/EstateManagement.Contract.DomainEvents/EstateManagement.Contract.DomainEvents.csproj
+++ b/EstateManagement.Contract.DomainEvents/EstateManagement.Contract.DomainEvents.csproj
@@ -6,7 +6,7 @@
-
+
diff --git a/EstateManagement.ContractAggregate/EstateManagement.ContractAggregate.csproj b/EstateManagement.ContractAggregate/EstateManagement.ContractAggregate.csproj
index 73279f60..e4705b47 100644
--- a/EstateManagement.ContractAggregate/EstateManagement.ContractAggregate.csproj
+++ b/EstateManagement.ContractAggregate/EstateManagement.ContractAggregate.csproj
@@ -6,9 +6,9 @@
-
+
-
+
diff --git a/EstateManagement.Database/EstateManagement.Database.csproj b/EstateManagement.Database/EstateManagement.Database.csproj
index 845189c2..0d931b4e 100644
--- a/EstateManagement.Database/EstateManagement.Database.csproj
+++ b/EstateManagement.Database/EstateManagement.Database.csproj
@@ -19,9 +19,9 @@
-
+
-
+
diff --git a/EstateManagement.Estate.DomainEvents/EstateManagement.Estate.DomainEvents.csproj b/EstateManagement.Estate.DomainEvents/EstateManagement.Estate.DomainEvents.csproj
index 643f2a3d..063caef0 100644
--- a/EstateManagement.Estate.DomainEvents/EstateManagement.Estate.DomainEvents.csproj
+++ b/EstateManagement.Estate.DomainEvents/EstateManagement.Estate.DomainEvents.csproj
@@ -6,6 +6,6 @@
-
+
diff --git a/EstateManagement.EstateAggregate/EstateManagement.EstateAggregate.csproj b/EstateManagement.EstateAggregate/EstateManagement.EstateAggregate.csproj
index da41231b..f7a3166b 100644
--- a/EstateManagement.EstateAggregate/EstateManagement.EstateAggregate.csproj
+++ b/EstateManagement.EstateAggregate/EstateManagement.EstateAggregate.csproj
@@ -6,9 +6,9 @@
-
+
-
+
diff --git a/EstateManagement.IntegrationTesting.Helpers/EstateManagement.IntegrationTesting.Helpers.csproj b/EstateManagement.IntegrationTesting.Helpers/EstateManagement.IntegrationTesting.Helpers.csproj
index 8596f681..35a4d128 100644
--- a/EstateManagement.IntegrationTesting.Helpers/EstateManagement.IntegrationTesting.Helpers.csproj
+++ b/EstateManagement.IntegrationTesting.Helpers/EstateManagement.IntegrationTesting.Helpers.csproj
@@ -7,7 +7,7 @@
-
+
diff --git a/EstateManagement.IntegrationTests/EstateManagement.IntegrationTests.csproj b/EstateManagement.IntegrationTests/EstateManagement.IntegrationTests.csproj
index 00d7db99..dd0e1e3c 100644
--- a/EstateManagement.IntegrationTests/EstateManagement.IntegrationTests.csproj
+++ b/EstateManagement.IntegrationTests/EstateManagement.IntegrationTests.csproj
@@ -11,7 +11,7 @@
-
+
@@ -19,8 +19,8 @@
-
-
+
+
diff --git a/EstateManagement.Merchant.DomainEvents/EstateManagement.Merchant.DomainEvents.csproj b/EstateManagement.Merchant.DomainEvents/EstateManagement.Merchant.DomainEvents.csproj
index c8f0eda9..ecba1956 100644
--- a/EstateManagement.Merchant.DomainEvents/EstateManagement.Merchant.DomainEvents.csproj
+++ b/EstateManagement.Merchant.DomainEvents/EstateManagement.Merchant.DomainEvents.csproj
@@ -6,7 +6,7 @@
-
+
diff --git a/EstateManagement.MerchantAggregate/EstateManagement.MerchantAggregate.csproj b/EstateManagement.MerchantAggregate/EstateManagement.MerchantAggregate.csproj
index f037eddc..6a795edb 100644
--- a/EstateManagement.MerchantAggregate/EstateManagement.MerchantAggregate.csproj
+++ b/EstateManagement.MerchantAggregate/EstateManagement.MerchantAggregate.csproj
@@ -6,8 +6,8 @@
-
-
+
+
diff --git a/EstateManagement.MerchantDepositAggregate/EstateManagement.MerchantDepositListAggregate.csproj b/EstateManagement.MerchantDepositAggregate/EstateManagement.MerchantDepositListAggregate.csproj
index 119cd45f..eebafcf6 100644
--- a/EstateManagement.MerchantDepositAggregate/EstateManagement.MerchantDepositListAggregate.csproj
+++ b/EstateManagement.MerchantDepositAggregate/EstateManagement.MerchantDepositListAggregate.csproj
@@ -5,8 +5,8 @@
-
-
+
+
diff --git a/EstateManagement.MerchantStatement.DomainEvents/EstateManagement.MerchantStatement.DomainEvents.csproj b/EstateManagement.MerchantStatement.DomainEvents/EstateManagement.MerchantStatement.DomainEvents.csproj
index d42d2550..029895b8 100644
--- a/EstateManagement.MerchantStatement.DomainEvents/EstateManagement.MerchantStatement.DomainEvents.csproj
+++ b/EstateManagement.MerchantStatement.DomainEvents/EstateManagement.MerchantStatement.DomainEvents.csproj
@@ -6,7 +6,7 @@
-
+
diff --git a/EstateManagement.MerchantStatementAggregate/EstateManagement.MerchantStatementAggregate.csproj b/EstateManagement.MerchantStatementAggregate/EstateManagement.MerchantStatementAggregate.csproj
index 2d7227a8..b4f33370 100644
--- a/EstateManagement.MerchantStatementAggregate/EstateManagement.MerchantStatementAggregate.csproj
+++ b/EstateManagement.MerchantStatementAggregate/EstateManagement.MerchantStatementAggregate.csproj
@@ -6,7 +6,7 @@
-
+
diff --git a/EstateManagement.Operator.DomainEvents/EstateManagement.Operator.DomainEvents.csproj b/EstateManagement.Operator.DomainEvents/EstateManagement.Operator.DomainEvents.csproj
index 254129bc..cf876f67 100644
--- a/EstateManagement.Operator.DomainEvents/EstateManagement.Operator.DomainEvents.csproj
+++ b/EstateManagement.Operator.DomainEvents/EstateManagement.Operator.DomainEvents.csproj
@@ -8,7 +8,7 @@
-
+
diff --git a/EstateManagement.OperatorAggregate/EstateManagement.OperatorAggregate.csproj b/EstateManagement.OperatorAggregate/EstateManagement.OperatorAggregate.csproj
index 0327fab4..31f334ce 100644
--- a/EstateManagement.OperatorAggregate/EstateManagement.OperatorAggregate.csproj
+++ b/EstateManagement.OperatorAggregate/EstateManagement.OperatorAggregate.csproj
@@ -7,9 +7,9 @@
-
+
-
+
diff --git a/EstateManagement.Repository/EstateManagement.Repository.csproj b/EstateManagement.Repository/EstateManagement.Repository.csproj
index b6b95b4b..e343d23a 100644
--- a/EstateManagement.Repository/EstateManagement.Repository.csproj
+++ b/EstateManagement.Repository/EstateManagement.Repository.csproj
@@ -2,15 +2,15 @@
net8.0
- None
+ Full
-
-
+
+
diff --git a/EstateManagement.Testing/TestData.cs b/EstateManagement.Testing/TestData.cs
index 2777070b..44bbc083 100644
--- a/EstateManagement.Testing/TestData.cs
+++ b/EstateManagement.Testing/TestData.cs
@@ -666,8 +666,8 @@ public class TestData{
TestData.PostCode,
TestData.Country);
- public static AddSettledFeeToMerchantStatementRequest AddSettledFeeToMerchantStatementRequest =>
- AddSettledFeeToMerchantStatementRequest.Create(TestData.EstateId,
+ public static MerchantStatementCommands.AddSettledFeeToMerchantStatementCommand AddSettledFeeToMerchantStatementCommand =>
+ new(TestData.EstateId,
TestData.MerchantId,
TestData.SettledFeeDateTime1,
TestData.SettledFeeAmount1,
@@ -684,8 +684,8 @@ public static DataTransferObjects.Requests.Contract.AddTransactionFeeForProductT
FeeType = DataTransferObjects.Responses.Contract.FeeType.Merchant
};
- public static AddTransactionToMerchantStatementRequest AddTransactionToMerchantStatementRequest =>
- AddTransactionToMerchantStatementRequest.Create(TestData.EstateId,
+ public static MerchantStatementCommands.AddTransactionToMerchantStatementCommand AddTransactionToMerchantStatementCommand =>
+ new(TestData.EstateId,
TestData.MerchantId,
TestData.TransactionDateTime1,
TestData.TransactionAmount1,
@@ -932,7 +932,7 @@ public static DataTransferObjects.Requests.Contract.AddTransactionFeeForProductT
TestData.DeviceIdentifier,
TestData.NewDeviceIdentifier);
- public static EmailMerchantStatementRequest EmailMerchantStatementRequest => EmailMerchantStatementRequest.Create(TestData.EstateId, TestData.MerchantId, TestData.MerchantStatementId);
+ public static MerchantStatementCommands.EmailMerchantStatementCommand EmailMerchantStatementCommand => new(TestData.EstateId, TestData.MerchantId, TestData.MerchantStatementId);
///
/// The estate created event
diff --git a/EstateManagement/Bootstrapper/MediatorRegistry.cs b/EstateManagement/Bootstrapper/MediatorRegistry.cs
index e5aa4682..db60fda7 100644
--- a/EstateManagement/Bootstrapper/MediatorRegistry.cs
+++ b/EstateManagement/Bootstrapper/MediatorRegistry.cs
@@ -75,10 +75,10 @@ public MediatorRegistry()
this.AddSingleton>, ContractRequestHandler>();
this.AddSingleton>>, ContractRequestHandler>();
- this.AddSingleton, MerchantStatementRequestHandler>();
- this.AddSingleton, MerchantStatementRequestHandler>();
+ this.AddSingleton, MerchantStatementRequestHandler>();
+ this.AddSingleton, MerchantStatementRequestHandler>();
this.AddSingleton, MerchantStatementRequestHandler>();
- this.AddSingleton, MerchantStatementRequestHandler>();
+ this.AddSingleton, MerchantStatementRequestHandler>();
this.AddSingleton>,
SettlementRequestHandler>();
diff --git a/EstateManagement/EstateManagement.csproj b/EstateManagement/EstateManagement.csproj
index d0fa6b28..0d66f523 100644
--- a/EstateManagement/EstateManagement.csproj
+++ b/EstateManagement/EstateManagement.csproj
@@ -36,7 +36,7 @@
-
+