diff --git a/CallbackHander.Testing/TestData.cs b/CallbackHander.Testing/TestData.cs
index a0e1ff1..7feaa2f 100644
--- a/CallbackHander.Testing/TestData.cs
+++ b/CallbackHander.Testing/TestData.cs
@@ -2,50 +2,49 @@
using CallbackHandlers.Models;
using Xunit;
-namespace CallbackHander.Testing
-{
- using CallbackHandler.BusinessLogic.Requests;
- using CallbackHandler.CallbackMessageAggregate;
+namespace CallbackHander.Testing;
- public class TestData
- {
- public static Guid CallbackId = Guid.Parse("E82DF060-5717-4F79-B99B-E14C702C8F0E");
+using CallbackHandler.BusinessLogic.Requests;
+using CallbackHandler.CallbackMessageAggregate;
- public static Int32 MessageFormat = 1;
+public class TestData
+{
+ public static Guid CallbackId = Guid.Parse("E82DF060-5717-4F79-B99B-E14C702C8F0E");
- public static String TypeString = "TestTypeString";
+ public static Int32 MessageFormat = 1;
- public static String CallbackMessage = "Callback message";
+ public static String TypeString = "TestTypeString";
- public static String[] Destinations = new[] {"A", "B"};
+ public static String CallbackMessage = "Callback message";
- public static String Reference = "640E863C23E244BDB9717C92733FFD4C-9D20A3961CF645EDAA7BDD436318BA29";
- public static Guid EstateReference = Guid.Parse("640E863C-23E2-44BD-B971-7C92733FFD4C");
- public static Guid MerchantReference = Guid.Parse("9D20A396-1CF6-45ED-AA7B-DD436318BA29");
+ public static String[] Destinations = {"A", "B"};
- public static CallbackCommands.RecordCallbackRequest RecordCallbackRequest =>
- new CallbackCommands.RecordCallbackRequest(TestData.CallbackId,
- TestData.CallbackMessage,
- TestData.Destinations,
- (MessageFormat)TestData.MessageFormat,
- TestData.TypeString,
- TestData.Reference);
+ public static String Reference = "640E863C23E244BDB9717C92733FFD4C-9D20A3961CF645EDAA7BDD436318BA29";
+ public static Guid EstateReference = Guid.Parse("640E863C-23E2-44BD-B971-7C92733FFD4C");
+ public static Guid MerchantReference = Guid.Parse("9D20A396-1CF6-45ED-AA7B-DD436318BA29");
- public static CallbackQueries.GetCallbackQuery GetCallbackQuery =>
- new CallbackQueries.GetCallbackQuery(TestData.CallbackId);
+ public static CallbackCommands.RecordCallbackRequest RecordCallbackRequest =>
+ new CallbackCommands.RecordCallbackRequest(TestData.CallbackId,
+ TestData.CallbackMessage,
+ TestData.Destinations,
+ (MessageFormat)TestData.MessageFormat,
+ TestData.TypeString,
+ TestData.Reference);
- public static CallbackMessageAggregate EmptyCallbackMessageAggregate()
- {
- return new CallbackMessageAggregate();
- }
+ public static CallbackQueries.GetCallbackQuery GetCallbackQuery =>
+ new CallbackQueries.GetCallbackQuery(TestData.CallbackId);
- public static CallbackMessageAggregate RecordedCallbackMessageAggregate()
- {
- CallbackMessageAggregate aggregate = new();
- aggregate.RecordCallback(TestData.CallbackId, TestData.TypeString, (MessageFormat)TestData.MessageFormat,
- TestData.CallbackMessage, TestData.Reference, TestData.Destinations, EstateReference, MerchantReference);
+ public static CallbackMessageAggregate EmptyCallbackMessageAggregate()
+ {
+ return new CallbackMessageAggregate();
+ }
+
+ public static CallbackMessageAggregate RecordedCallbackMessageAggregate()
+ {
+ CallbackMessageAggregate aggregate = new();
+ aggregate.RecordCallback(TestData.CallbackId, TestData.TypeString, (MessageFormat)TestData.MessageFormat,
+ TestData.CallbackMessage, TestData.Reference, TestData.Destinations, EstateReference, MerchantReference);
- return aggregate;
- }
+ return aggregate;
}
}
diff --git a/CallbackHandler.BusinessLogic/Common/DomainEventTypesToSilentlyHandle.cs b/CallbackHandler.BusinessLogic/Common/DomainEventTypesToSilentlyHandle.cs
index c05d1c6..44fddf3 100644
--- a/CallbackHandler.BusinessLogic/Common/DomainEventTypesToSilentlyHandle.cs
+++ b/CallbackHandler.BusinessLogic/Common/DomainEventTypesToSilentlyHandle.cs
@@ -1,56 +1,55 @@
-namespace CallbackHandler.BusinessLogic.Common
+namespace CallbackHandler.BusinessLogic.Common;
+
+using System;
+using System.Collections.Generic;
+using System.Diagnostics.CodeAnalysis;
+using System.Linq;
+using Shared.DomainDrivenDesign.EventSourcing;
+
+[ExcludeFromCodeCoverage]
+public class DomainEventTypesToSilentlyHandle : IDomainEventTypesToSilentlyHandle
{
- using System;
- using System.Collections.Generic;
- using System.Diagnostics.CodeAnalysis;
- using System.Linq;
- using Shared.DomainDrivenDesign.EventSourcing;
-
- [ExcludeFromCodeCoverage]
- public class DomainEventTypesToSilentlyHandle : IDomainEventTypesToSilentlyHandle
- {
- #region Fields
+ #region Fields
- ///
- /// The handler event types to silently handle
- ///
- private readonly Dictionary HandlerEventTypesToSilentlyHandle;
+ ///
+ /// The handler event types to silently handle
+ ///
+ private readonly Dictionary HandlerEventTypesToSilentlyHandle;
- #endregion
+ #endregion
- #region Constructors
+ #region Constructors
- ///
- /// Initializes a new instance of the class.
- ///
- /// The handler event types to silently handle.
- public DomainEventTypesToSilentlyHandle(Dictionary handlerEventTypesToSilentlyHandle)
- {
- this.HandlerEventTypesToSilentlyHandle = handlerEventTypesToSilentlyHandle;
- }
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ /// The handler event types to silently handle.
+ public DomainEventTypesToSilentlyHandle(Dictionary handlerEventTypesToSilentlyHandle)
+ {
+ this.HandlerEventTypesToSilentlyHandle = handlerEventTypesToSilentlyHandle;
+ }
- #endregion
+ #endregion
- #region Methods
+ #region Methods
- ///
- /// Handles the silently.
- ///
- /// Name of the handler.
- /// The domain event.
- ///
- public Boolean HandleSilently(String handlerName,
- DomainEvent domainEvent)
+ ///
+ /// Handles the silently.
+ ///
+ /// Name of the handler.
+ /// The domain event.
+ ///
+ public Boolean HandleSilently(String handlerName,
+ DomainEvent domainEvent)
+ {
+ if (this.HandlerEventTypesToSilentlyHandle.TryGetValue(handlerName, out var eventTypes)
+ && eventTypes.Contains(domainEvent.GetType().FullName))
{
- if (this.HandlerEventTypesToSilentlyHandle.TryGetValue(handlerName, out var eventTypes)
- && eventTypes.Contains(domainEvent.GetType().FullName))
- {
- return true;
- }
+ return true;
+ }
- return false;
+ return false;
}
#endregion
- }
}
\ No newline at end of file
diff --git a/CallbackHandler.BusinessLogic/Common/IDomainEventTypesToSilentlyHandle.cs b/CallbackHandler.BusinessLogic/Common/IDomainEventTypesToSilentlyHandle.cs
index 3b14789..6886e99 100644
--- a/CallbackHandler.BusinessLogic/Common/IDomainEventTypesToSilentlyHandle.cs
+++ b/CallbackHandler.BusinessLogic/Common/IDomainEventTypesToSilentlyHandle.cs
@@ -1,21 +1,20 @@
-namespace CallbackHandler.BusinessLogic.Common
-{
- using System;
- using Shared.DomainDrivenDesign.EventSourcing;
+namespace CallbackHandler.BusinessLogic.Common;
+
+using System;
+using Shared.DomainDrivenDesign.EventSourcing;
- public interface IDomainEventTypesToSilentlyHandle
- {
- #region Methods
+public interface IDomainEventTypesToSilentlyHandle
+{
+ #region Methods
- ///
- /// Handles the silently.
- ///
- /// Name of the handler.
- /// The domain event.
- ///
- Boolean HandleSilently(String handlerName,
- DomainEvent domainEvent);
+ ///
+ /// Handles the silently.
+ ///
+ /// Name of the handler.
+ /// The domain event.
+ ///
+ Boolean HandleSilently(String handlerName,
+ DomainEvent domainEvent);
- #endregion
- }
+ #endregion
}
\ No newline at end of file
diff --git a/CallbackHandler.BusinessLogic/RequestHandler/CallbackHandlerRequestHandler.cs b/CallbackHandler.BusinessLogic/RequestHandler/CallbackHandlerRequestHandler.cs
index ef71587..cdbaf79 100644
--- a/CallbackHandler.BusinessLogic/RequestHandler/CallbackHandlerRequestHandler.cs
+++ b/CallbackHandler.BusinessLogic/RequestHandler/CallbackHandlerRequestHandler.cs
@@ -1,50 +1,49 @@
using Shared.Results;
using SimpleResults;
-namespace CallbackHandler.BusinessLogic.RequestHandler
+namespace CallbackHandler.BusinessLogic.RequestHandler;
+
+using System.Threading;
+using System.Threading.Tasks;
+using CallbackHandler.BusinessLogic.Services;
+using CallbackMessageAggregate;
+using MediatR;
+using Requests;
+using Shared.DomainDrivenDesign.EventSourcing;
+using Shared.EventStore.Aggregate;
+
+public class CallbackHandlerRequestHandler : IRequestHandler,
+ IRequestHandler>
{
- using System.Threading;
- using System.Threading.Tasks;
- using CallbackHandler.BusinessLogic.Services;
- using CallbackMessageAggregate;
- using MediatR;
- using Requests;
- using Shared.DomainDrivenDesign.EventSourcing;
- using Shared.EventStore.Aggregate;
-
- public class CallbackHandlerRequestHandler : IRequestHandler,
- IRequestHandler>
+ private readonly ICallbackDomainService CallbackDomainService;
+ private readonly IAggregateRepository CallbackAggregateRepository;
+
+ public CallbackHandlerRequestHandler(ICallbackDomainService callbackDomainService,
+ IAggregateRepository callbackAggregateRepository)
+ {
+ this.CallbackDomainService = callbackDomainService;
+ CallbackAggregateRepository = callbackAggregateRepository;
+ }
+
+ public async Task Handle(CallbackCommands.RecordCallbackRequest request,
+ CancellationToken cancellationToken) {
+
+ return await this.CallbackDomainService.RecordCallback(request.CallbackId,
+ request.TypeString,
+ request.MessageFormat,
+ request.CallbackMessage,
+ request.Reference,
+ request.Destinations,
+ cancellationToken);
+ }
+
+ public async Task> Handle(CallbackQueries.GetCallbackQuery request, CancellationToken cancellationToken)
{
- private readonly ICallbackDomainService CallbackDomainService;
- private readonly IAggregateRepository CallbackAggregateRepository;
-
- public CallbackHandlerRequestHandler(ICallbackDomainService callbackDomainService,
- IAggregateRepository callbackAggregateRepository)
- {
- this.CallbackDomainService = callbackDomainService;
- CallbackAggregateRepository = callbackAggregateRepository;
- }
-
- public async Task Handle(CallbackCommands.RecordCallbackRequest request,
- CancellationToken cancellationToken) {
-
- return await this.CallbackDomainService.RecordCallback(request.CallbackId,
- request.TypeString,
- request.MessageFormat,
- request.CallbackMessage,
- request.Reference,
- request.Destinations,
- cancellationToken);
- }
-
- public async Task> Handle(CallbackQueries.GetCallbackQuery request, CancellationToken cancellationToken)
- {
- Result callbackAggregate =
- await this.CallbackAggregateRepository.GetLatestVersion(request.CallbackId, cancellationToken);
- if (callbackAggregate.IsFailed)
- return ResultHelpers.CreateFailure(callbackAggregate);
-
- return Result.Success(callbackAggregate.Data.GetCallbackMessage());
- }
+ Result callbackAggregate =
+ await this.CallbackAggregateRepository.GetLatestVersion(request.CallbackId, cancellationToken);
+ if (callbackAggregate.IsFailed)
+ return ResultHelpers.CreateFailure(callbackAggregate);
+
+ return Result.Success(callbackAggregate.Data.GetCallbackMessage());
}
}
\ No newline at end of file
diff --git a/CallbackHandler.BusinessLogic/Services/ICallbackDomainService.cs b/CallbackHandler.BusinessLogic/Services/ICallbackDomainService.cs
index bf61feb..c6797f4 100644
--- a/CallbackHandler.BusinessLogic/Services/ICallbackDomainService.cs
+++ b/CallbackHandler.BusinessLogic/Services/ICallbackDomainService.cs
@@ -9,16 +9,15 @@
using System.Threading.Tasks;
using SimpleResults;
-namespace CallbackHandler.BusinessLogic.Services
+namespace CallbackHandler.BusinessLogic.Services;
+
+public interface ICallbackDomainService
{
- public interface ICallbackDomainService
- {
- Task RecordCallback(Guid callbackId,
- String typeString,
- MessageFormat messageFormat,
- String callbackMessage,
- String reference,
- String[] destinations,
- CancellationToken cancellationToken);
- }
+ Task RecordCallback(Guid callbackId,
+ String typeString,
+ MessageFormat messageFormat,
+ String callbackMessage,
+ String reference,
+ String[] destinations,
+ CancellationToken cancellationToken);
}
diff --git a/CallbackHandler/Bootstrapper/MiddlewareRegistry.cs b/CallbackHandler/Bootstrapper/MiddlewareRegistry.cs
index 668ac50..636663d 100644
--- a/CallbackHandler/Bootstrapper/MiddlewareRegistry.cs
+++ b/CallbackHandler/Bootstrapper/MiddlewareRegistry.cs
@@ -1,56 +1,56 @@
using Microsoft.Extensions.Logging;
-namespace CallbackHandler.Bootstrapper
-{
- using System;
- using System.Collections.Generic;
- using System.Diagnostics.CodeAnalysis;
- using System.IO;
- using System.Reflection;
- using Common;
- using EventStore.Client;
- using Lamar;
- using Microsoft.Extensions.Configuration;
- using Microsoft.Extensions.DependencyInjection;
- using Microsoft.Extensions.Diagnostics.HealthChecks;
- using Microsoft.OpenApi.Models;
- using Newtonsoft.Json;
- using Newtonsoft.Json.Serialization;
- using Shared.EventStore.Extensions;
- using Shared.General;
- using Shared.Middleware;
- using Swashbuckle.AspNetCore.Filters;
+namespace CallbackHandler.Bootstrapper;
+
+using System;
+using System.Collections.Generic;
+using System.Diagnostics.CodeAnalysis;
+using System.IO;
+using System.Reflection;
+using Common;
+using EventStore.Client;
+using Lamar;
+using Microsoft.Extensions.Configuration;
+using Microsoft.Extensions.DependencyInjection;
+using Microsoft.Extensions.Diagnostics.HealthChecks;
+using Microsoft.OpenApi.Models;
+using Newtonsoft.Json;
+using Newtonsoft.Json.Serialization;
+using Shared.EventStore.Extensions;
+using Shared.General;
+using Shared.Middleware;
+using Swashbuckle.AspNetCore.Filters;
- [ExcludeFromCodeCoverage]
- public class MiddlewareRegistry :ServiceRegistry
+[ExcludeFromCodeCoverage]
+public class MiddlewareRegistry :ServiceRegistry
+{
+ public MiddlewareRegistry()
{
- public MiddlewareRegistry()
- {
- String connectionString = Startup.Configuration.GetValue("EventStoreSettings:ConnectionString");
- EventStoreClientSettings eventStoreSettings = EventStoreClientSettings.Create(connectionString);
+ String connectionString = Startup.Configuration.GetValue("EventStoreSettings:ConnectionString");
+ EventStoreClientSettings eventStoreSettings = EventStoreClientSettings.Create(connectionString);
- this.AddHealthChecks().AddEventStore(eventStoreSettings,
- userCredentials: eventStoreSettings.DefaultCredentials,
- name: "Eventstore",
- failureStatus: HealthStatus.Unhealthy,
- tags: new[] { "db", "eventstore" });
+ this.AddHealthChecks().AddEventStore(eventStoreSettings,
+ userCredentials: eventStoreSettings.DefaultCredentials,
+ name: "Eventstore",
+ failureStatus: HealthStatus.Unhealthy,
+ tags: new[] { "db", "eventstore" });
- this.AddSwaggerGen(c =>
- {
- c.SwaggerDoc("v1", new OpenApiInfo
- {
- Title = "Callback Handler API",
- Version = "1.0",
- Description = "A REST Api to handle callback requests from external parties API's.",
- Contact = new OpenApiContact
- {
- Name = "Stuart Ferguson",
- Email = "golfhandicapping@btinternet.com"
- }
- });
- // add a custom operation filter which sets default values
- c.OperationFilter();
- c.ExampleFilters();
+ this.AddSwaggerGen(c =>
+ {
+ c.SwaggerDoc("v1", new OpenApiInfo
+ {
+ Title = "Callback Handler API",
+ Version = "1.0",
+ Description = "A REST Api to handle callback requests from external parties API's.",
+ Contact = new OpenApiContact
+ {
+ Name = "Stuart Ferguson",
+ Email = "golfhandicapping@btinternet.com"
+ }
+ });
+ // add a custom operation filter which sets default values
+ c.OperationFilter();
+ c.ExampleFilters();
//Locate the XML files being generated by ASP.NET...
DirectoryInfo directory = new(AppContext.BaseDirectory);
@@ -86,5 +86,4 @@ public MiddlewareRegistry()
this.AddSingleton(config);
}
- }
}