Skip to content

Commit

Permalink
Merge pull request #267 from THC-Software/main
Browse files Browse the repository at this point in the history
merge main into release/v1.0
  • Loading branch information
iiNomad23 authored Jul 11, 2024
2 parents 26131e2 + d93a8ef commit a368b1f
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,29 +35,31 @@ public async Task Handle(DomainEnvelope<IDomainEvent> domainEnvelope)
var tennisClubReadModel =
await tennisClubReadModelRepository.GetTennisClubById(tournamentReadModel.TennisClubId);

if (tennisClubReadModel == null)
if (tennisClubReadModel != null)
{
loggerService.LogTennisClubNotFound(tournamentReadModel.TennisClubId);
throw new TennisClubNotFoundException(domainEnvelope.EntityId);
}

await tournamentReadModelRepository.Delete(tournamentReadModel);
var members = await memberReadModelRepository.GetMembersByTennisClubId(tennisClubReadModel.TennisClubId.Id);
var mailSubject = $"Tournament {tournamentReadModel.Name} canceled";
var mailBody = $"""
Unfortunately the tournament '{tournamentReadModel.Name}' that would have been taking
place from the {tournamentReadModel.StartDate} to the {tournamentReadModel.EndDate} has
been canceled.
""";

var members = await memberReadModelRepository.GetMembersByTennisClubId(tennisClubReadModel.TennisClubId.Id);
var mailSubject = $"Tournament {tournamentReadModel.Name} canceled";
var mailBody = $"""
Unfortunately the tournament '{tournamentReadModel.Name}' that would have been taking
place from the {tournamentReadModel.StartDate} to the {tournamentReadModel.EndDate} has
been canceled.
""";

foreach (var member in members)
foreach (var member in members)
{
var emailMessage = new EmailMessage(Guid.NewGuid(), member.Email, mailSubject, mailBody,
DateTime.UtcNow);
await emailOutboxRepository.Add(emailMessage);
}
}
else
{
var emailMessage = new EmailMessage(Guid.NewGuid(), member.Email, mailSubject, mailBody,
DateTime.UtcNow);
await emailOutboxRepository.Add(emailMessage);
// We can't throw an exception here because deleting a tennis club triggers
// that all associated tournaments are deleted.
loggerService.LogTennisClubNotFound(tournamentReadModel.TennisClubId);
}

await tournamentReadModelRepository.Delete(tournamentReadModel);
loggerService.LogTournamentCanceled(tournamentReadModel.TournamentId);
}

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,7 @@ services:
### Kubernetes

We split all the Kubernetes files by kind (config, secrets, deployment, and services).
The secrets contain for mailhog the sender email encoded in Base64 and for postgres the username and password also encoded in Base64.
The secrets contain for postgres the username and password encoded in Base64.
All the configuration files can be applied using `kubectl apply -R -f deployments`.

All the files used to configure Kubernetes are located here:\
Expand Down

0 comments on commit a368b1f

Please sign in to comment.