Skip to content

Commit

Permalink
Update packages
Browse files Browse the repository at this point in the history
Moving from CreateConfirmationEmailMessage (command) to use the AppointmentScheduledIntegrationEvent type.
  • Loading branch information
ardalis committed Apr 27, 2021
1 parent f764204 commit 16b9a38
Show file tree
Hide file tree
Showing 18 changed files with 79 additions and 105 deletions.
22 changes: 11 additions & 11 deletions FrontDesk/src/FrontDesk.Api/FrontDesk.Api.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -94,27 +94,27 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Ardalis.ApiEndpoints" Version="3.0.0" />
<PackageReference Include="Ardalis.ApiEndpoints" Version="3.1.0" />
<PackageReference Include="AutoMapper.Extensions.Microsoft.DependencyInjection" Version="8.1.1" />
<PackageReference Include="MediatR.Extensions.Microsoft.DependencyInjection" Version="9.0.0" />
<PackageReference Include="Microsoft.AspNetCore.SignalR.Core" Version="1.1.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="5.0.4" />
<PackageReference Include="Microsoft.EntityFrameworkCore.InMemory" Version="5.0.4" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Relational" Version="5.0.4" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="5.0.4" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="5.0.4">
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="5.0.5" />
<PackageReference Include="Microsoft.EntityFrameworkCore.InMemory" Version="5.0.5" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Relational" Version="5.0.5" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="5.0.5" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="5.0.5">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.10.9" />
<PackageReference Include="MediatR" Version="9.0.0" />
<PackageReference Include="PluralsightDdd.SharedKernel" Version="2.0.0" />
<PackageReference Include="PluralsightDdd.SharedKernel" Version="2.1.0" />
<PackageReference Include="RabbitMQ.Client" Version="6.2.1" />
<PackageReference Include="SixLabors.ImageSharp" Version="1.0.3" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.1.1" />
<PackageReference Include="Swashbuckle.AspNetCore.Annotations" Version="6.1.1" />
<PackageReference Include="Swashbuckle.AspNetCore.SwaggerUI" Version="6.1.1" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="5.0.4" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.1.3" />
<PackageReference Include="Swashbuckle.AspNetCore.Annotations" Version="6.1.3" />
<PackageReference Include="Swashbuckle.AspNetCore.SwaggerUI" Version="6.1.3" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="5.0.5" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.Server" Version="5.0.4" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.Server" Version="5.0.5" />
</ItemGroup>

<ItemGroup>
Expand Down
6 changes: 3 additions & 3 deletions FrontDesk/src/FrontDesk.Blazor/FrontDesk.Blazor.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@

<ItemGroup>
<PackageReference Include="Blazored.LocalStorage" Version="3.0.0" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="5.0.4" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.DevServer" Version="5.0.4" PrivateAssets="all" />
<PackageReference Include="Microsoft.AspNetCore.SignalR.Client" Version="5.0.4" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="5.0.5" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.DevServer" Version="5.0.5" PrivateAssets="all" />
<PackageReference Include="Microsoft.AspNetCore.SignalR.Client" Version="5.0.5" />
<PackageReference Include="System.Net.Http.Json" Version="5.0.0" />
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.10.9" />
<!--<PackageReference Include="Telerik.UI.for.Blazor.Trial.DDD" Version="2.21.0" />-->
Expand Down
Original file line number Diff line number Diff line change
@@ -1,29 +1,28 @@
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; }
public string EventType
{
get
{
return nameof(AppointmentConfirmedAppEvent);
return nameof(AppointmentConfirmedIntegrationEvent);
}
}
}
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,18 +1,22 @@
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; }
public string PatientName { get; set; }
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);
}
}
2 changes: 1 addition & 1 deletion FrontDesk/src/FrontDesk.Core/FrontDesk.Core.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<PackageReference Include="Ardalis.GuardClauses" Version="3.1.0" />
<PackageReference Include="Ardalis.Result" Version="3.1.1" />
<PackageReference Include="MediatR" Version="9.0.0" />
<PackageReference Include="PluralsightDdd.SharedKernel" Version="2.0.0" />
<PackageReference Include="PluralsightDdd.SharedKernel" Version="2.1.0" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ namespace FrontDesk.Core.Handlers
/// <summary>
/// This handler responds to incoming messages saying a user has confirmed an appointment
/// </summary>
public class EmailConfirmationHandler : INotificationHandler<AppointmentConfirmedAppEvent>
public class EmailConfirmationHandler : INotificationHandler<AppointmentConfirmedIntegrationEvent>
{
private readonly IRepository<Schedule> _scheduleRepository;
private readonly IReadRepository<Schedule> _scheduleReadRepository;
Expand All @@ -33,7 +33,7 @@ public EmailConfirmationHandler(IRepository<Schedule> scheduleRepository,
_logger = logger;
}

public async Task Handle(AppointmentConfirmedAppEvent appointmentConfirmedEvent,
public async Task Handle(AppointmentConfirmedIntegrationEvent appointmentConfirmedEvent,
CancellationToken cancellationToken)
{
_logger.LogInformation($"Handling appointment confirmation: {appointmentConfirmedEvent.AppointmentId}");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
39 changes: 22 additions & 17 deletions FrontDesk/src/FrontDesk.Infrastructure/Data/CachedRepository.cs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -32,9 +33,9 @@ public Task<T> AddAsync(T entity)
return _sourceRepository.AddAsync(entity);
}

public Task<int> CountAsync(ISpecification<T> specification)
public Task<int> CountAsync(ISpecification<T> specification, CancellationToken cancellationToken = default)
{
return _sourceRepository.CountAsync(specification);
return _sourceRepository.CountAsync(specification, cancellationToken);
}

public Task DeleteAsync(T entity)
Expand All @@ -47,19 +48,20 @@ public Task DeleteRangeAsync(IEnumerable<T> entities)
return _sourceRepository.DeleteRangeAsync(entities);
}

public Task<T> GetByIdAsync<TId>(TId id)
public Task<T> GetByIdAsync<TId>(TId id, CancellationToken cancellationToken = default)
{
string key = $"{typeof(T).Name}-{id}";
_logger.LogInformation("Checking cache for " + key);
return _cache.GetOrCreate(key, entry =>
{
entry.SetOptions(_cacheOptions);
_logger.LogWarning("Fetching source data for " + key);
return _sourceRepository.GetByIdAsync(id);
return _sourceRepository.GetByIdAsync(id, cancellationToken);
});
}

public Task<T> GetBySpecAsync<Spec>(Spec specification) where Spec : ISingleResultSpecification, ISpecification<T>
public Task<T> GetBySpecAsync<Spec>(Spec specification,
CancellationToken cancellationToken = default) where Spec : ISingleResultSpecification, ISpecification<T>
{
if (specification.CacheEnabled)
{
Expand All @@ -69,13 +71,14 @@ public Task<T> GetBySpecAsync<Spec>(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<TResult> GetBySpecAsync<TResult>(ISpecification<T, TResult> specification)
public Task<TResult> GetBySpecAsync<TResult>(ISpecification<T, TResult> specification,
CancellationToken cancellationToken = default)
{
if (specification.CacheEnabled)
{
Expand All @@ -85,25 +88,26 @@ public Task<TResult> GetBySpecAsync<TResult>(ISpecification<T, TResult> 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<List<T>> ListAsync()
public Task<List<T>> ListAsync(CancellationToken cancellationToken = default)
{
string key = $"{typeof(T).Name}-List";
_logger.LogInformation($"Checking cache for {key}");
return _cache.GetOrCreate(key, entry =>
{
entry.SetOptions(_cacheOptions);
_logger.LogWarning($"Fetching source data for {key}");
return _sourceRepository.ListAsync();
return _sourceRepository.ListAsync(cancellationToken);
});
}

public Task<List<T>> ListAsync(ISpecification<T> specification)
public Task<List<T>> ListAsync(ISpecification<T> specification,
CancellationToken cancellationToken = default)
{
if (specification.CacheEnabled)
{
Expand All @@ -113,13 +117,14 @@ public Task<List<T>> ListAsync(ISpecification<T> 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<List<TResult>> ListAsync<TResult>(ISpecification<T, TResult> specification)
public Task<List<TResult>> ListAsync<TResult>(ISpecification<T, TResult> specification,
CancellationToken cancellationToken = default)
{
if (specification.CacheEnabled)
{
Expand All @@ -129,10 +134,10 @@ public Task<List<TResult>> ListAsync<TResult>(ISpecification<T, TResult> 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()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,18 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Ardalis.Specification.EntityFrameworkCore" Version="5.0.3" />
<PackageReference Include="Autofac" Version="6.1.0" />
<PackageReference Include="Ardalis.Specification.EntityFrameworkCore" Version="5.1.0" />
<PackageReference Include="Autofac" Version="6.2.0" />
<PackageReference Include="Autofac.Extensions.DependencyInjection" Version="7.1.0" />
<PackageReference Include="Ardalis.EFCore.Extensions" Version="1.1.0" />
<PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="5.0.4" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" PrivateAssets="all" Version="5.0.4" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="5.0.4" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="5.0.4" />
<PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="5.0.5" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" PrivateAssets="all" Version="5.0.5" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="5.0.5" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="5.0.5" />
<PackageReference Include="Microsoft.Extensions.Logging" Version="5.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="5.0.0" />
<PackageReference Include="Microsoft.Extensions.ObjectPool" Version="5.0.4" />
<PackageReference Include="PluralsightDdd.SharedKernel" Version="2.0.0" />
<PackageReference Include="Microsoft.Extensions.ObjectPool" Version="5.0.5" />
<PackageReference Include="PluralsightDdd.SharedKernel" Version="2.1.0" />
<PackageReference Include="RabbitMQ.Client" Version="6.2.1" />
<PackageReference Include="SQLite" Version="3.13.0" />
<PackageReference Include="NETStandard.Library" Version="2.0.3" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public RabbitMessagePublisher(IPooledObjectPolicy<IModel> objectPolicy,
_logger = logger;
}

public void Publish(CreateConfirmationEmailMessage eventToPublish)
public void Publish(AppointmentScheduledIntegrationEvent eventToPublish)
{
Guard.Against.Null(eventToPublish, nameof(eventToPublish));

Expand Down
6 changes: 3 additions & 3 deletions FrontDesk/tests/FunctionalTests/FunctionalTests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

<ItemGroup>
<PackageReference Include="Ardalis.HttpClientTestExtensions" Version="1.0.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.9.1" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.9.4" />
<PackageReference Include="xunit" Version="2.4.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3">
<PrivateAssets>all</PrivateAssets>
Expand All @@ -17,8 +17,8 @@
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.AspNetCore.Mvc.Testing" Version="5.0.4" />
<PackageReference Include="Microsoft.EntityFrameworkCore.InMemory" Version="5.0.4" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.Testing" Version="5.0.5" />
<PackageReference Include="Microsoft.EntityFrameworkCore.InMemory" Version="5.0.5" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
</ItemGroup>

Expand Down
Loading

0 comments on commit 16b9a38

Please sign in to comment.