Skip to content

Commit

Permalink
Merge branch 'main' into documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
iiNomad23 authored Jul 10, 2024
2 parents 5364ec5 + 6169a3b commit 4d68195
Show file tree
Hide file tree
Showing 19 changed files with 455 additions and 200 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
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>
68 changes: 34 additions & 34 deletions ClubService.Infrastructure/DbContexts/EventStoreDbContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,40 +36,10 @@ protected override void OnModelCreating(ModelBuilder modelBuilder)
DateTime.UtcNow,
new SystemOperatorRegisteredEvent(
new SystemOperatorId(new Guid("1588ec27-c932-4dee-a341-d18c8108a711")), "systemoperator")
)
);
}

public async Task SeedTestData()
{
// We need to seed the test data like this so that the events are inserted in the right order into the db
// With HasData the order is not the same like in the code and then debezium fetches the events in the wrong order
var domainEvents = new List<DomainEnvelope<IDomainEvent>>
{
// Subscription Tiers
new(
new Guid("8d4d3eff-b77b-4e21-963b-e211366bb94b"),
new Guid("38888969-d579-46ec-9cd6-0208569a077e"),
EventType.SUBSCRIPTION_TIER_CREATED,
EntityType.SUBSCRIPTION_TIER,
DateTime.UtcNow,
new SubscriptionTierCreatedEvent(
new SubscriptionTierId(new Guid("38888969-d579-46ec-9cd6-0208569a077e")),
"Gorilla Subscription Tier",
200)
),
new(
new Guid("e335d85a-f844-4c7e-b608-035ef00af733"),
new Guid("d19073ba-f760-4a9a-abfa-f8215d96bec7"),
EventType.SUBSCRIPTION_TIER_CREATED,
EntityType.SUBSCRIPTION_TIER,
DateTime.UtcNow,
new SubscriptionTierCreatedEvent(
new SubscriptionTierId(new Guid("d19073ba-f760-4a9a-abfa-f8215d96bec7")),
"Bison Subscription Tier",
250)
),
new(

// Subscription Tiers
new DomainEnvelope<IDomainEvent>(
new Guid("36db98d7-8fea-4715-923c-74192b147752"),
new Guid("4c148d45-ebc8-4bbf-aa9a-d491eb185ad5"),
EventType.SUBSCRIPTION_TIER_CREATED,
Expand All @@ -80,7 +50,7 @@ public async Task SeedTestData()
"Guinea Pig Subscription Tier",
100)
),
new(
new DomainEnvelope<IDomainEvent>(
new Guid("3b591696-d9c9-4e30-a6a1-6a1439c5580b"),
new Guid("2bebd11c-bf8e-4448-886f-0cb8608af7ca"),
EventType.SUBSCRIPTION_TIER_CREATED,
Expand All @@ -91,7 +61,37 @@ public async Task SeedTestData()
"Woolf Subscription Tier",
150)
),
new DomainEnvelope<IDomainEvent>(
new Guid("8d4d3eff-b77b-4e21-963b-e211366bb94b"),
new Guid("38888969-d579-46ec-9cd6-0208569a077e"),
EventType.SUBSCRIPTION_TIER_CREATED,
EntityType.SUBSCRIPTION_TIER,
DateTime.UtcNow,
new SubscriptionTierCreatedEvent(
new SubscriptionTierId(new Guid("38888969-d579-46ec-9cd6-0208569a077e")),
"Gorilla Subscription Tier",
200)
),
new DomainEnvelope<IDomainEvent>(
new Guid("e335d85a-f844-4c7e-b608-035ef00af733"),
new Guid("d19073ba-f760-4a9a-abfa-f8215d96bec7"),
EventType.SUBSCRIPTION_TIER_CREATED,
EntityType.SUBSCRIPTION_TIER,
DateTime.UtcNow,
new SubscriptionTierCreatedEvent(
new SubscriptionTierId(new Guid("d19073ba-f760-4a9a-abfa-f8215d96bec7")),
"Bison Subscription Tier",
250)
)
);
}

public async Task SeedTestData()
{
// We need to seed the test data like this so that the events are inserted in the right order into the db
// With HasData the order is not the same as in the code and then debezium fetches the events in the wrong order
var domainEvents = new List<DomainEnvelope<IDomainEvent>>
{
// Tennis Clubs
new(
new Guid("049af565-a42d-4f02-b213-793459e4873f"),
Expand Down

This file was deleted.

This file was deleted.

Loading

0 comments on commit 4d68195

Please sign in to comment.