public async Task <ActionResult <IEnumerable <PersonAllocation> > > AllocatePersonsToPlace( [FromBody] PersonAllocation[] allocations, [FromQuery] string placeId ) { try { if (allocations is null || allocations.Length == 0) { throw new ArgumentNullException(nameof(allocations)); } if (string.IsNullOrEmpty(placeId)) { throw new ArgumentNullException(nameof(placeId)); } if (!await User.IsPlaceAdmin(userRepository, placeProviderRepository, placeRepository, placeId)) { throw new Exception("Only place provider admin can assign person to place"); } var ret = new List <PersonAllocation>(); foreach (var allocation in allocations) { ret.Add(await placeProviderRepository.AllocatePerson(allocation, placeId)); } return(Ok(ret)); } catch (ArgumentException exc) { logger.LogError(exc.Message); return(BadRequest(new ProblemDetails() { Detail = exc.Message })); } catch (Exception exc) { logger.LogError(exc, exc.Message); return(BadRequest(new ProblemDetails() { Detail = exc.Message })); } }