Skip to content

Commit

Permalink
Merge branch 'main' into fix-tournament-confirmed-event
Browse files Browse the repository at this point in the history
  • Loading branch information
Smightym8 authored Jul 10, 2024
2 parents d66adea + 9d4c2d6 commit bea52ca
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 1 deletion.
12 changes: 11 additions & 1 deletion ClubService.API/Program.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using ClubService.API;
using ClubService.API.ApplicationConfigurations;
using ClubService.Domain.Repository;
using ClubService.Infrastructure.DbContexts;
using Microsoft.AspNetCore.Authentication;
using Microsoft.EntityFrameworkCore;
Expand Down Expand Up @@ -66,7 +67,16 @@
app.UseSwaggerUI(options => { options.SwaggerEndpoint("/swagger/v1/swagger.json", "ClubServiceV1"); });

await eventStoreDbContext.Database.EnsureCreatedAsync();
await eventStoreDbContext.SeedTestData();

try
{
await eventStoreDbContext.SeedTestData();
}
catch (DbUpdateException)
{
var logger = services.GetRequiredService<ILoggerService<Program>>();
logger.LogDuplicateSeedData();
}

await readStoreDbContext.Database.EnsureDeletedAsync();
await readStoreDbContext.Database.EnsureCreatedAsync();
Expand Down
1 change: 1 addition & 0 deletions ClubService.Domain/Repository/ILoggerService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -65,4 +65,5 @@ public interface ILoggerService<T>
void LogEmailMessageRelayStop();
void LogSystemOperatorRegistered(Guid id);
void LogInvalidEMailAddress(string emailAddress);
void LogDuplicateSeedData();
}
5 changes: 5 additions & 0 deletions ClubService.Infrastructure/Logging/LoggerService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -325,4 +325,9 @@ public void LogInvalidEMailAddress(string emailAddress)
{
logger.LogError("The following email address is invalid: {emailMessageRecipientEMailAddress}", emailAddress);
}

public void LogDuplicateSeedData()
{
logger.LogInformation("Seed data already seeded");
}
}

0 comments on commit bea52ca

Please sign in to comment.