From 48f65220da92af16b02ea91f69e500830aaa53d6 Mon Sep 17 00:00:00 2001 From: Jonathan Idland Olsnes <73334350+Jonathanio123@users.noreply.github.com> Date: Wed, 28 Aug 2024 16:13:47 +0200 Subject: [PATCH] Rewrote invalid profiles check --- .../Controllers/DepartmentsController.cs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/Fusion.Summary.Api/Controllers/DepartmentsController.cs b/src/Fusion.Summary.Api/Controllers/DepartmentsController.cs index 96f10cc7d..fc96419cc 100644 --- a/src/Fusion.Summary.Api/Controllers/DepartmentsController.cs +++ b/src/Fusion.Summary.Api/Controllers/DepartmentsController.cs @@ -126,8 +126,13 @@ public async Task PutV1(string sapDepartmentId, [FromBody] PutDep .Concat(request.DelegateResourceOwnersAzureUniqueId) .Select(p => new PersonIdentifier(p)); - if ((await ResolvePersonsAsync(personIdentifiers)).FirstOrDefault(r => !r.Success) is { } unresolvedProfile) - return BadRequest($"{unresolvedProfile.Identifier} could not be resolved"); + var unresolvedProfiles = (await ResolvePersonsAsync(personIdentifiers)) + .Where(r => !r.Success) + .ToList(); + + if (unresolvedProfiles.Count != 0) + return BadRequest($"Profiles: {string.Join(',', unresolvedProfiles)} could not be resolved"); + var department = await DispatchAsync(new GetDepartment(sapDepartmentId));