diff --git a/FrontDesk/src/FrontDesk.Api/FrontDesk.Api.csproj b/FrontDesk/src/FrontDesk.Api/FrontDesk.Api.csproj index d3bc9608..0c114e7f 100644 --- a/FrontDesk/src/FrontDesk.Api/FrontDesk.Api.csproj +++ b/FrontDesk/src/FrontDesk.Api/FrontDesk.Api.csproj @@ -94,27 +94,27 @@ - + - - - - - + + + + + all runtime; build; native; contentfiles; analyzers; buildtransitive - + - - - - + + + + diff --git a/FrontDesk/src/FrontDesk.Api/VetClinicPublicRabbitMqService.cs b/FrontDesk/src/FrontDesk.Api/VetClinicPublicRabbitMqService.cs index 0c5aa6b8..5b5e031b 100644 --- a/FrontDesk/src/FrontDesk.Api/VetClinicPublicRabbitMqService.cs +++ b/FrontDesk/src/FrontDesk.Api/VetClinicPublicRabbitMqService.cs @@ -116,7 +116,7 @@ private async Task HandleMessage(string message) { Guid appointmentId = root.GetProperty("AppointmentId").GetGuid(); DateTimeOffset dateTimeOffset = root.GetProperty("DateTimeEventOccurred").GetDateTimeOffset(); - var appEvent = new AppointmentConfirmedAppEvent(dateTimeOffset) + var appEvent = new AppointmentConfirmedIntegrationEvent(dateTimeOffset) { AppointmentId = appointmentId }; diff --git a/FrontDesk/src/FrontDesk.Blazor.Host/FrontDesk.Blazor.Host.csproj b/FrontDesk/src/FrontDesk.Blazor.Host/FrontDesk.Blazor.Host.csproj index 632157d9..da895849 100644 --- a/FrontDesk/src/FrontDesk.Blazor.Host/FrontDesk.Blazor.Host.csproj +++ b/FrontDesk/src/FrontDesk.Blazor.Host/FrontDesk.Blazor.Host.csproj @@ -5,7 +5,7 @@ - + diff --git a/FrontDesk/src/FrontDesk.Blazor/FrontDesk.Blazor.csproj b/FrontDesk/src/FrontDesk.Blazor/FrontDesk.Blazor.csproj index af0c8aab..6527070c 100644 --- a/FrontDesk/src/FrontDesk.Blazor/FrontDesk.Blazor.csproj +++ b/FrontDesk/src/FrontDesk.Blazor/FrontDesk.Blazor.csproj @@ -24,9 +24,9 @@ - - - + + + diff --git a/FrontDesk/src/FrontDesk.Core/Events/IntegrationEvents/AppointmentConfirmedAppEvent.cs b/FrontDesk/src/FrontDesk.Core/Events/IntegrationEvents/AppointmentConfirmedIntegrationEvent.cs similarity index 50% rename from FrontDesk/src/FrontDesk.Core/Events/IntegrationEvents/AppointmentConfirmedAppEvent.cs rename to FrontDesk/src/FrontDesk.Core/Events/IntegrationEvents/AppointmentConfirmedIntegrationEvent.cs index 725f23ed..632a8af5 100644 --- a/FrontDesk/src/FrontDesk.Core/Events/IntegrationEvents/AppointmentConfirmedAppEvent.cs +++ b/FrontDesk/src/FrontDesk.Core/Events/IntegrationEvents/AppointmentConfirmedIntegrationEvent.cs @@ -1,21 +1,20 @@ using System; -using MediatR; -using PluralsightDdd.SharedKernel.Interfaces; +using PluralsightDdd.SharedKernel; namespace FrontDesk.Core.Events.IntegrationEvents { // This is fired by the message queue handler when an appointment should // be marked confirmed. It happens before the appointment is confirmed in // the model. - public class AppointmentConfirmedAppEvent : IIntegrationEvent, INotification + public class AppointmentConfirmedIntegrationEvent : BaseIntegrationEvent { - public AppointmentConfirmedAppEvent() : this(DateTime.Now) + public AppointmentConfirmedIntegrationEvent() : this(DateTimeOffset.Now) { } - public AppointmentConfirmedAppEvent(DateTimeOffset dateOccurred) + public AppointmentConfirmedIntegrationEvent(DateTimeOffset dateOccurred) { - DateOccurred = dateOccurred.DateTime; + DateOccurred = dateOccurred; } public Guid AppointmentId { get; set; } @@ -23,7 +22,7 @@ public string EventType { get { - return nameof(AppointmentConfirmedAppEvent); + return nameof(AppointmentConfirmedIntegrationEvent); } } } diff --git a/FrontDesk/src/FrontDesk.Core/Events/IntegrationEvents/AppointmentScheduledAppEvent.cs b/FrontDesk/src/FrontDesk.Core/Events/IntegrationEvents/AppointmentScheduledAppEvent.cs deleted file mode 100644 index 62c18add..00000000 --- a/FrontDesk/src/FrontDesk.Core/Events/IntegrationEvents/AppointmentScheduledAppEvent.cs +++ /dev/null @@ -1,35 +0,0 @@ -using System; -using BlazorShared.Models.Appointment; -using PluralsightDdd.SharedKernel; - -namespace FrontDesk.Core.Events.IntegrationEvents -{ - public class AppointmentScheduledAppEvent : BaseDomainEvent - { - public AppointmentScheduledAppEvent() - { - DateOccurred = DateTime.Now; - } - - public AppointmentScheduledDTO AppointmentScheduled { get; set; } - public string EventType - { - get - { - return nameof(AppointmentScheduledAppEvent); - } - } - - public class AppointmentScheduledDTO - { - public Guid AppointmentId { get; set; } - public string ClientName { get; set; } - public string ClientEmailAddress { get; set; } - public string PatientName { get; set; } - public string DoctorName { get; set; } - public string AppointmentType { get; set; } - public DateTime Start { get; set; } - public DateTime End { get; set; } - } - } -} diff --git a/FrontDesk/src/FrontDesk.Core/Events/IntegrationEvents/CreateConfirmationEmailMessage.cs b/FrontDesk/src/FrontDesk.Core/Events/IntegrationEvents/AppointmentScheduledIntegrationEvent.cs similarity index 59% rename from FrontDesk/src/FrontDesk.Core/Events/IntegrationEvents/CreateConfirmationEmailMessage.cs rename to FrontDesk/src/FrontDesk.Core/Events/IntegrationEvents/AppointmentScheduledIntegrationEvent.cs index beff6ab5..637018f4 100644 --- a/FrontDesk/src/FrontDesk.Core/Events/IntegrationEvents/CreateConfirmationEmailMessage.cs +++ b/FrontDesk/src/FrontDesk.Core/Events/IntegrationEvents/AppointmentScheduledIntegrationEvent.cs @@ -1,10 +1,15 @@ using System; -using PluralsightDdd.SharedKernel.Interfaces; +using PluralsightDdd.SharedKernel; namespace FrontDesk.Core.Events.IntegrationEvents { - public class CreateConfirmationEmailMessage : IIntegrationEvent + public class AppointmentScheduledIntegrationEvent : BaseIntegrationEvent { + public AppointmentScheduledIntegrationEvent() + { + DateOccurred = DateTimeOffset.Now; + } + public Guid AppointmentId { get; set; } public string ClientName { get; set; } public string ClientEmailAddress { get; set; } @@ -12,7 +17,6 @@ public class CreateConfirmationEmailMessage : IIntegrationEvent public string DoctorName { get; set; } public string AppointmentType { get; set; } public DateTimeOffset AppointmentStartDateTime { get; set; } - - public string EventType => nameof(CreateConfirmationEmailMessage); + public string EventType => nameof(AppointmentScheduledIntegrationEvent); } } diff --git a/FrontDesk/src/FrontDesk.Core/FrontDesk.Core.csproj b/FrontDesk/src/FrontDesk.Core/FrontDesk.Core.csproj index 8b00a566..a1ec81f5 100644 --- a/FrontDesk/src/FrontDesk.Core/FrontDesk.Core.csproj +++ b/FrontDesk/src/FrontDesk.Core/FrontDesk.Core.csproj @@ -15,7 +15,7 @@ - + diff --git a/FrontDesk/src/FrontDesk.Core/Handlers/EmailConfirmationHandler.cs b/FrontDesk/src/FrontDesk.Core/Handlers/EmailConfirmationHandler.cs index 1c6af0d9..003f74a4 100644 --- a/FrontDesk/src/FrontDesk.Core/Handlers/EmailConfirmationHandler.cs +++ b/FrontDesk/src/FrontDesk.Core/Handlers/EmailConfirmationHandler.cs @@ -15,7 +15,7 @@ namespace FrontDesk.Core.Handlers /// /// This handler responds to incoming messages saying a user has confirmed an appointment /// - public class EmailConfirmationHandler : INotificationHandler + public class EmailConfirmationHandler : INotificationHandler { private readonly IRepository _scheduleRepository; private readonly IReadRepository _scheduleReadRepository; @@ -33,7 +33,7 @@ public EmailConfirmationHandler(IRepository scheduleRepository, _logger = logger; } - public async Task Handle(AppointmentConfirmedAppEvent appointmentConfirmedEvent, + public async Task Handle(AppointmentConfirmedIntegrationEvent appointmentConfirmedEvent, CancellationToken cancellationToken) { _logger.LogInformation($"Handling appointment confirmation: {appointmentConfirmedEvent.AppointmentId}"); diff --git a/FrontDesk/src/FrontDesk.Core/Handlers/RelayAppointmentScheduledService.cs b/FrontDesk/src/FrontDesk.Core/Handlers/RelayAppointmentScheduledService.cs index c8660330..c60ea528 100644 --- a/FrontDesk/src/FrontDesk.Core/Handlers/RelayAppointmentScheduledService.cs +++ b/FrontDesk/src/FrontDesk.Core/Handlers/RelayAppointmentScheduledService.cs @@ -39,11 +39,12 @@ public RelayAppointmentScheduledHandler( _logger = logger; } - public async Task Handle(AppointmentScheduledEvent appointmentScheduledEvent, CancellationToken cancellationToken) + public async Task Handle(AppointmentScheduledEvent appointmentScheduledEvent, + CancellationToken cancellationToken) { _logger.LogInformation("Handling appointmentScheduledEvent"); - // we are translating from a domain event to an application event here - var newMessage = new CreateConfirmationEmailMessage(); + // we are translating from a domain event to an integration event here + var newMessage = new AppointmentScheduledIntegrationEvent(); var appt = appointmentScheduledEvent.AppointmentScheduled; diff --git a/FrontDesk/src/FrontDesk.Core/Interfaces/IMessagePublisher.cs b/FrontDesk/src/FrontDesk.Core/Interfaces/IMessagePublisher.cs index 9bfb8fef..137956b2 100644 --- a/FrontDesk/src/FrontDesk.Core/Interfaces/IMessagePublisher.cs +++ b/FrontDesk/src/FrontDesk.Core/Interfaces/IMessagePublisher.cs @@ -4,6 +4,6 @@ namespace FrontDesk.Core.Interfaces public interface IMessagePublisher { // for now we only need to publish one event type, so we're using its type specifically here. - void Publish(CreateConfirmationEmailMessage eventToPublish); + void Publish(AppointmentScheduledIntegrationEvent eventToPublish); } } diff --git a/FrontDesk/src/FrontDesk.Infrastructure/Data/CachedRepository.cs b/FrontDesk/src/FrontDesk.Infrastructure/Data/CachedRepository.cs index a10de594..4c7abc2b 100644 --- a/FrontDesk/src/FrontDesk.Infrastructure/Data/CachedRepository.cs +++ b/FrontDesk/src/FrontDesk.Infrastructure/Data/CachedRepository.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Threading; using System.Threading.Tasks; using Ardalis.Specification; using Microsoft.Extensions.Caching.Memory; @@ -32,9 +33,9 @@ public Task AddAsync(T entity) return _sourceRepository.AddAsync(entity); } - public Task CountAsync(ISpecification specification) + public Task CountAsync(ISpecification specification, CancellationToken cancellationToken = default) { - return _sourceRepository.CountAsync(specification); + return _sourceRepository.CountAsync(specification, cancellationToken); } public Task DeleteAsync(T entity) @@ -47,7 +48,7 @@ public Task DeleteRangeAsync(IEnumerable entities) return _sourceRepository.DeleteRangeAsync(entities); } - public Task GetByIdAsync(TId id) + public Task GetByIdAsync(TId id, CancellationToken cancellationToken = default) { string key = $"{typeof(T).Name}-{id}"; _logger.LogInformation("Checking cache for " + key); @@ -55,11 +56,12 @@ public Task GetByIdAsync(TId id) { entry.SetOptions(_cacheOptions); _logger.LogWarning("Fetching source data for " + key); - return _sourceRepository.GetByIdAsync(id); + return _sourceRepository.GetByIdAsync(id, cancellationToken); }); } - public Task GetBySpecAsync(Spec specification) where Spec : ISingleResultSpecification, ISpecification + public Task GetBySpecAsync(Spec specification, + CancellationToken cancellationToken = default) where Spec : ISingleResultSpecification, ISpecification { if (specification.CacheEnabled) { @@ -69,13 +71,14 @@ public Task GetBySpecAsync(Spec specification) where Spec : ISingleResu { entry.SetOptions(_cacheOptions); _logger.LogWarning("Fetching source data for " + key); - return _sourceRepository.GetBySpecAsync(specification); + return _sourceRepository.GetBySpecAsync(specification, cancellationToken); }); } return _sourceRepository.GetBySpecAsync(specification); } - public Task GetBySpecAsync(ISpecification specification) + public Task GetBySpecAsync(ISpecification specification, + CancellationToken cancellationToken = default) { if (specification.CacheEnabled) { @@ -85,13 +88,13 @@ public Task GetBySpecAsync(ISpecification specific { entry.SetOptions(_cacheOptions); _logger.LogWarning("Fetching source data for " + key); - return _sourceRepository.GetBySpecAsync(specification); + return _sourceRepository.GetBySpecAsync(specification, cancellationToken); }); } - return _sourceRepository.GetBySpecAsync(specification); + return _sourceRepository.GetBySpecAsync(specification, cancellationToken); } - public Task> ListAsync() + public Task> ListAsync(CancellationToken cancellationToken = default) { string key = $"{typeof(T).Name}-List"; _logger.LogInformation($"Checking cache for {key}"); @@ -99,11 +102,12 @@ public Task> ListAsync() { entry.SetOptions(_cacheOptions); _logger.LogWarning($"Fetching source data for {key}"); - return _sourceRepository.ListAsync(); + return _sourceRepository.ListAsync(cancellationToken); }); } - public Task> ListAsync(ISpecification specification) + public Task> ListAsync(ISpecification specification, + CancellationToken cancellationToken = default) { if (specification.CacheEnabled) { @@ -113,13 +117,14 @@ public Task> ListAsync(ISpecification specification) { entry.SetOptions(_cacheOptions); _logger.LogWarning($"Fetching source data for {key}"); - return _sourceRepository.ListAsync(specification); + return _sourceRepository.ListAsync(specification, cancellationToken); }); } - return _sourceRepository.ListAsync(specification); + return _sourceRepository.ListAsync(specification, cancellationToken); } - public Task> ListAsync(ISpecification specification) + public Task> ListAsync(ISpecification specification, + CancellationToken cancellationToken = default) { if (specification.CacheEnabled) { @@ -129,10 +134,10 @@ public Task> ListAsync(ISpecification specifi { entry.SetOptions(_cacheOptions); _logger.LogWarning($"Fetching source data for {key}"); - return _sourceRepository.ListAsync(specification); + return _sourceRepository.ListAsync(specification, cancellationToken); }); } - return _sourceRepository.ListAsync(specification); + return _sourceRepository.ListAsync(specification, cancellationToken); } public Task SaveChangesAsync() diff --git a/FrontDesk/src/FrontDesk.Infrastructure/FrontDesk.Infrastructure.csproj b/FrontDesk/src/FrontDesk.Infrastructure/FrontDesk.Infrastructure.csproj index 5732d78d..00615af8 100644 --- a/FrontDesk/src/FrontDesk.Infrastructure/FrontDesk.Infrastructure.csproj +++ b/FrontDesk/src/FrontDesk.Infrastructure/FrontDesk.Infrastructure.csproj @@ -6,18 +6,18 @@ - - + + - - - - + + + + - - + + diff --git a/FrontDesk/src/FrontDesk.Infrastructure/Messaging/RabbitMessagePublisher.cs b/FrontDesk/src/FrontDesk.Infrastructure/Messaging/RabbitMessagePublisher.cs index e3cc4c4d..57acad8a 100644 --- a/FrontDesk/src/FrontDesk.Infrastructure/Messaging/RabbitMessagePublisher.cs +++ b/FrontDesk/src/FrontDesk.Infrastructure/Messaging/RabbitMessagePublisher.cs @@ -23,7 +23,7 @@ public RabbitMessagePublisher(IPooledObjectPolicy objectPolicy, _logger = logger; } - public void Publish(CreateConfirmationEmailMessage eventToPublish) + public void Publish(AppointmentScheduledIntegrationEvent eventToPublish) { Guard.Against.Null(eventToPublish, nameof(eventToPublish)); diff --git a/FrontDesk/tests/FunctionalTests/FunctionalTests.csproj b/FrontDesk/tests/FunctionalTests/FunctionalTests.csproj index de8f598f..a31436d2 100644 --- a/FrontDesk/tests/FunctionalTests/FunctionalTests.csproj +++ b/FrontDesk/tests/FunctionalTests/FunctionalTests.csproj @@ -7,7 +7,7 @@ - + all @@ -17,8 +17,8 @@ all runtime; build; native; contentfiles; analyzers; buildtransitive - - + + diff --git a/FrontDesk/tests/IntegrationTests/IntegrationTests.csproj b/FrontDesk/tests/IntegrationTests/IntegrationTests.csproj index 87fed730..838fe00c 100644 --- a/FrontDesk/tests/IntegrationTests/IntegrationTests.csproj +++ b/FrontDesk/tests/IntegrationTests/IntegrationTests.csproj @@ -6,9 +6,9 @@ - - - + + + diff --git a/FrontDesk/tests/UnitTests/UnitTests.csproj b/FrontDesk/tests/UnitTests/UnitTests.csproj index 3294df2e..d35fcba3 100644 --- a/FrontDesk/tests/UnitTests/UnitTests.csproj +++ b/FrontDesk/tests/UnitTests/UnitTests.csproj @@ -7,8 +7,8 @@ - - + + runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/SharedKernel/src/PluralsightDdd.SharedKernel/PluralsightDdd.SharedKernel.csproj b/SharedKernel/src/PluralsightDdd.SharedKernel/PluralsightDdd.SharedKernel.csproj index ff7f6c6e..921f8fde 100644 --- a/SharedKernel/src/PluralsightDdd.SharedKernel/PluralsightDdd.SharedKernel.csproj +++ b/SharedKernel/src/PluralsightDdd.SharedKernel/PluralsightDdd.SharedKernel.csproj @@ -12,8 +12,8 @@ Includes common abstractions and base types. https://github.com/ardalis/pluralsight-ddd-fundamentals aspnet asp.net aspnetcore asp.net core ddd dddesign value object entity aggregate domain event pluralsight - Add BaseIntegrationEvent; remove IIntegrationEvent. - 2.1.0 + Update NuGet dependencies. + 2.1.1 PluralsightDdd.SharedKernel https://user-images.githubusercontent.com/782127/33497760-facf6550-d69c-11e7-94e4-b3856da259a9.png true