Skip to content

Commit

Permalink
Merge pull request #253 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 10, 2024
2 parents d327589 + 0f2b243 commit 250e0a7
Show file tree
Hide file tree
Showing 23 changed files with 660 additions and 236 deletions.
2 changes: 2 additions & 0 deletions ClubService.API/Controller/AdminController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ public class AdminController(
[ProducesResponseType(StatusCodes.Status404NotFound)]
[ProducesResponseType(StatusCodes.Status400BadRequest)]
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
[Consumes("application/json")]
[Authorize(Roles = "ADMIN")]
public async Task<ActionResult<Guid>> RegisterAdmin(
[FromBody] AdminRegisterCommand adminRegisterCommand)
Expand Down Expand Up @@ -57,6 +58,7 @@ public async Task<ActionResult<Guid>> DeleteAdmin(Guid id)
[ProducesResponseType(StatusCodes.Status404NotFound)]
[ProducesResponseType(StatusCodes.Status400BadRequest)]
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
[Consumes("application/json")]
[Authorize(Roles = "ADMIN")]
public async Task<ActionResult<Guid>> UpdateAdmin(Guid id, [FromBody] AdminUpdateCommand adminUpdateCommand)
{
Expand Down
4 changes: 3 additions & 1 deletion ClubService.API/Controller/MemberController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ public async Task<ActionResult<MemberReadModel>> GetMemberById(Guid id)
[ProducesResponseType(StatusCodes.Status403Forbidden)]
[ProducesResponseType(StatusCodes.Status404NotFound)]
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
[Consumes("application/json")]
[Authorize(Roles = "ADMIN")]
public async Task<ActionResult<Guid>> RegisterMember([FromBody] MemberRegisterCommand memberRegisterCommand)
{
Expand All @@ -73,8 +74,9 @@ public async Task<ActionResult<Guid>> RegisterMember([FromBody] MemberRegisterCo
[ProducesResponseType(StatusCodes.Status403Forbidden)]
[ProducesResponseType(StatusCodes.Status404NotFound)]
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
[Consumes("application/json")]
[Authorize(Roles = "MEMBER")]
public async Task<ActionResult<Guid>> UpdateMember(Guid id, MemberUpdateCommand memberUpdateCommand)
public async Task<ActionResult<Guid>> UpdateMember(Guid id, [FromBody] MemberUpdateCommand memberUpdateCommand)
{
var jwtUserId = User.Claims.FirstOrDefault(c => c.Type == "sub")?.Value;

Expand Down
2 changes: 2 additions & 0 deletions ClubService.API/Controller/TennisClubController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ public async Task<ActionResult<List<MemberReadModel>>> GetMembersByTennisClubId(
[ProducesResponseType(StatusCodes.Status404NotFound)]
[ProducesResponseType(StatusCodes.Status400BadRequest)]
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
[Consumes("application/json")]
public async Task<ActionResult<Guid>> RegisterTennisClub(
[FromBody] TennisClubRegisterCommand tennisClubRegisterCommand)
{
Expand All @@ -127,6 +128,7 @@ public async Task<ActionResult<Guid>> RegisterTennisClub(
[ProducesResponseType(StatusCodes.Status404NotFound)]
[ProducesResponseType(StatusCodes.Status400BadRequest)]
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
[Consumes("application/json")]
[Authorize(Roles = "ADMIN")]
public async Task<ActionResult<Guid>> UpdateTennisClub(
Guid id,
Expand Down
2 changes: 2 additions & 0 deletions ClubService.API/Controller/UserController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ public class UserController(ILoginService loginService, IUserService userService
[ProducesResponseType(StatusCodes.Status404NotFound)]
[ProducesResponseType(StatusCodes.Status400BadRequest)]
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
[Consumes("application/json")]
public async Task<ActionResult<UserInformationDto>> Login(
[FromBody] LoginCommand loginCommand)
{
Expand All @@ -32,6 +33,7 @@ public async Task<ActionResult<UserInformationDto>> Login(
[ProducesResponseType(StatusCodes.Status404NotFound)]
[ProducesResponseType(StatusCodes.Status400BadRequest)]
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
[Consumes("application/json")]
[Authorize(Roles = "SYSTEM_OPERATOR,ADMIN,MEMBER")]
public async Task<ActionResult> ChangePassword([FromBody] ChangePasswordCommand changePasswordCommand)
{
Expand Down
6 changes: 3 additions & 3 deletions ClubService.API/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,17 +47,17 @@
{
if (eventStoreDbContext.Database.GetPendingMigrations().Any())
{
eventStoreDbContext.Database.Migrate();
await eventStoreDbContext.Database.MigrateAsync();
}

if (readStoreDbContext.Database.GetPendingMigrations().Any())
{
readStoreDbContext.Database.Migrate();
await readStoreDbContext.Database.MigrateAsync();
}

if (loginStoreDbContext.Database.GetPendingMigrations().Any())
{
loginStoreDbContext.Database.Migrate();
await loginStoreDbContext.Database.MigrateAsync();
}
}
else if (app.Environment.IsDevelopment() || app.Environment.IsEnvironment("DockerDevelopment"))
Expand Down
4 changes: 2 additions & 2 deletions ClubService.Domain/Repository/IEmailOutboxRepository.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ namespace ClubService.Domain.Repository;
public interface IEmailOutboxRepository
{
Task Add(EmailMessage emailMessage);
Task<List<EmailMessage>> GetAllEmails();
Task RemoveEmails(List<EmailMessage> emails);
Task<List<EmailMessage>> GetAllEmailMessages();
Task Delete(EmailMessage emailMessage);
}
2 changes: 2 additions & 0 deletions ClubService.Infrastructure/ClubService.Infrastructure.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,9 @@
</ItemGroup>

<ItemGroup>
<Folder Include="Migrations\EventStore\" />
<Folder Include="Migrations\LoginStore\"/>
<Folder Include="Migrations\ReadStore\" />
</ItemGroup>

</Project>
8 changes: 4 additions & 4 deletions ClubService.Infrastructure/EventHandling/RedisEventReader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -73,19 +73,19 @@ private async Task ConsumeMessages()
await db.StreamAcknowledgeAsync(stream.StreamName, stream.ConsumerGroup, entry.Id);
continue;
}

var parsedEvent = EventParser.ParseEvent(after);


// Here we filter out the events we don't want.
// If the EventTypes list contains an asterisk we want all the events of that stream.
// Otherwise, we check if the event type of the parsedEvent is in the list of desired events.
var parsedEventType = parsedEvent.EventType.ToString();
var parsedEventType = after.GetProperty("eventType").GetString();
if (!stream.DesiredEventTypes.Contains(AllEvents) &&
!stream.DesiredEventTypes.Contains(parsedEventType, StringComparer.OrdinalIgnoreCase))
{
await db.StreamAcknowledgeAsync(stream.StreamName, stream.ConsumerGroup, entry.Id);
continue;
}

var parsedEvent = EventParser.ParseEvent(after);

using var scope = _services.CreateScope();
var chainEventHandler = scope.ServiceProvider.GetRequiredService<ChainEventHandler>();
Expand Down
21 changes: 10 additions & 11 deletions ClubService.Infrastructure/Mail/EmailMessageRelay.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,23 +35,22 @@ private async Task SendEmails()
var emailOutboxRepository = scope.ServiceProvider.GetRequiredService<IEmailOutboxRepository>();
var transactionManager = scope.ServiceProvider.GetRequiredService<ITransactionManager>();

await transactionManager.TransactionScope(async () =>
{
var emails = await emailOutboxRepository.GetAllEmails();
var emailMessages = await emailOutboxRepository.GetAllEmailMessages();

foreach (var email in emails)
foreach (var emailMessage in emailMessages)
{
await transactionManager.TransactionScope(async () =>
{
var mailMessage = new MailMessage(_senderEmailAddress, email.RecipientEMailAddress)
var mailMessage = new MailMessage(_senderEmailAddress, emailMessage.RecipientEMailAddress)
{
Subject = email.Subject,
Body = email.Body
Subject = emailMessage.Subject,
Body = emailMessage.Body
};

await _smtpClient.SendMailAsync(mailMessage);
}

await emailOutboxRepository.RemoveEmails(emails);
});
await emailOutboxRepository.Delete(emailMessage);
});
}
}

protected override async Task ExecuteAsync(CancellationToken stoppingToken)
Expand Down

This file was deleted.

This file was deleted.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 250e0a7

Please sign in to comment.