Skip to content

Commit

Permalink
Merge pull request #40 from bennetrr/fix/accept-invite
Browse files Browse the repository at this point in the history
Fix/accept invite
  • Loading branch information
Bennet Ranft authored Mar 10, 2024
2 parents e566496 + a061135 commit 9d4169e
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 8 deletions.
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,14 @@ To configure the backend, use
the [.NET User Secret Manager](https://learn.microsoft.com/en-us/aspnet/core/security/app-secrets?view=aspnetcore-8.0&tabs=windows#secret-manager)
with the options from the [Configuration](#backend) section.

Before starting the backend, you need to run the database migration scripts:

```bash
# working directory: src/backend/Bennetr.BrickInv.Api/Bennetr.BrickInv.Api
dotnet ef database update --context BrickInvContext
dotnet ef database update --context IdentityContext
```

Then, start the backend:

```bash
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,16 +112,12 @@ public async Task<IActionResult> AcceptGroupInvite(string inviteId)

var invite = await context.GroupInvites
.Include(x => x.Recipient)
.Include(x => x.Group)
.Where(x => x.Id == inviteId)
.Where(x => x.Recipient.Id == currentUser.Id)
.FirstAsync();

var group = await context.Groups
.Include(x => x.Members)
.Where(x => x.Id == invite.Group.Id)
.FirstAsync();

group.Members.Add(invite.Recipient);
invite.Group.Members.Add(invite.Recipient);
context.GroupInvites.Remove(invite);

await context.SaveChangesAsync();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ public async Task<ActionResult<SetDto>> CreateSet(CreateSetRequest request)

return CreatedAtAction(
nameof(GetSet),
new { id = set.Id },
new { setId = set.Id },
set.Adapt<SetDto>()
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public async Task<ActionResult<UserProfileDto>> CreateUserProfile()

return CreatedAtAction(
nameof(GetUserProfile),
new { id = userProfile.Id },
new { userId = userProfile.Id },
userProfile.Adapt<UserProfileDto>()
);
}
Expand Down

0 comments on commit 9d4169e

Please sign in to comment.