diff --git a/src/IPA.Bcfier.App/Controllers/ProjectUsersController.cs b/src/IPA.Bcfier.App/Controllers/ProjectUsersController.cs index 7ad2ce8..61e5013 100644 --- a/src/IPA.Bcfier.App/Controllers/ProjectUsersController.cs +++ b/src/IPA.Bcfier.App/Controllers/ProjectUsersController.cs @@ -78,6 +78,14 @@ public async Task AddUserToProjectAsync(Guid projectId, [FromBody UserId = dbUser.Id, ProjectId = projectId }; + + identifierExistsAlready = await _context.ProjectUsers.AnyAsync(pu => pu.ProjectId == projectId + && pu.UserId == projectUser.UserId); + if (identifierExistsAlready) + { + return BadRequest(new ApiError("This user assignment already exists.")); + } + _context.ProjectUsers.Add(projectUser); await _context.SaveChangesAsync(); diff --git a/src/ipa-bcfier-ui/src/app/components/project-details/project-details.component.ts b/src/ipa-bcfier-ui/src/app/components/project-details/project-details.component.ts index 091ee7d..7135021 100644 --- a/src/ipa-bcfier-ui/src/app/components/project-details/project-details.component.ts +++ b/src/ipa-bcfier-ui/src/app/components/project-details/project-details.component.ts @@ -147,6 +147,9 @@ export class ProjectDetailsComponent implements OnDestroy { }, error: () => { this.notificationsService.error('Failed to add the user'); + this.users$ = this.getProjectUsers(this.data.id); + this.filterUsers(); + this.cdr.detectChanges(); }, }) );