diff --git a/src/backend/api/Fusion.Resources.Api/Controllers/Requests/InternalRequestsController.cs b/src/backend/api/Fusion.Resources.Api/Controllers/Requests/InternalRequestsController.cs index 51bd0bc85..8d708a038 100644 --- a/src/backend/api/Fusion.Resources.Api/Controllers/Requests/InternalRequestsController.cs +++ b/src/backend/api/Fusion.Resources.Api/Controllers/Requests/InternalRequestsController.cs @@ -109,6 +109,10 @@ public async Task> CreateProjectAlloc return Created($"/projects/{projectIdentifier}/requests/{newRequest!.RequestId}", new ApiResourceAllocationRequest(newRequest)); } + catch (InvalidOperationException iv) + { + return ApiErrors.InvalidOperation(iv); + } catch (ValidationException ex) { return ApiErrors.InvalidOperation(ex); @@ -193,6 +197,10 @@ public async Task> CreateProjectAlloc // Using the requests for position endpoint as created ref.. This is not completely accurate as it could return more than those created. Best option though. return Created($"/projects/{projectIdentifier}/positions/{request.OrgPositionId}/requests", requests.Select(x => new ApiResourceAllocationRequest(x)).ToList()); } + catch (InvalidOperationException iv) + { + return ApiErrors.InvalidOperation(iv); + } catch (ValidationException ex) { return ApiErrors.InvalidOperation(ex); @@ -287,6 +295,10 @@ public async Task> CreateResourceOwne return Created($"/departments/{departmentPath}/resources/requests/{newRequest!.RequestId}", new ApiResourceAllocationRequest(newRequest)); } + catch (InvalidOperationException iv) + { + return ApiErrors.InvalidOperation(iv); + } catch (ValidationException ex) { return ApiErrors.InvalidOperation(ex); @@ -363,6 +375,10 @@ public async Task> PatchInternalReque return new ApiResourceAllocationRequest(updatedRequest!); } + catch (InvalidOperationException iv) + { + return ApiErrors.InvalidOperation(iv); + } catch (ValidationException ve) { return ApiErrors.InvalidOperation(ve); diff --git a/src/backend/api/Fusion.Resources.Api/Controllers/Utilities/UtilitiesController.cs b/src/backend/api/Fusion.Resources.Api/Controllers/Utilities/UtilitiesController.cs index 67f57a4d6..f61125f91 100644 --- a/src/backend/api/Fusion.Resources.Api/Controllers/Utilities/UtilitiesController.cs +++ b/src/backend/api/Fusion.Resources.Api/Controllers/Utilities/UtilitiesController.cs @@ -22,7 +22,8 @@ public class UtilitiesController : ResourceControllerBase private readonly IFusionTokenProvider tokenProvider; private readonly IOptions fusionOptions; - public UtilitiesController(IHttpClientFactory httpClientFactory, IFusionTokenProvider tokenProvider, IOptions fusionOptions) + public UtilitiesController(IHttpClientFactory httpClientFactory, IFusionTokenProvider tokenProvider, + IOptions fusionOptions) { this.httpClientFactory = httpClientFactory; this.tokenProvider = tokenProvider; @@ -30,7 +31,8 @@ public UtilitiesController(IHttpClientFactory httpClientFactory, IFusionTokenPro } [HttpPost("/utilities/parse-spreadsheet")] - public async Task> ValidateContractorImportSpreadsheet([FromForm] ConvertSpreadsheetRequest request) + public async Task> ValidateContractorImportSpreadsheet( + [FromForm] ConvertSpreadsheetRequest request) { if (request == null) return FusionApiError.InvalidOperation("MissingBody", "Could not locate any body payload"); @@ -57,14 +59,16 @@ public async Task> ValidateContractorImportSpreads if (response.IsSuccessStatusCode) return JsonConvert.DeserializeObject(content)!; - throw new InvalidOperationException($"Parser function returned non-successfull response ({response.StatusCode})."); + throw new InvalidOperationException( + $"Parser function returned non-successfull response ({response.StatusCode})."); } [HttpGet("/utilities/templates/import-personnel")] public async Task DownloadImportPersonnelTemplate() { const string fileName = "fusion personnel import.xlsx"; - using var templateFile = Assembly.GetExecutingAssembly().GetManifestResourceStream("Fusion.Resources.Api.Data.personnel-import-template.xlsx"); + using var templateFile = Assembly.GetExecutingAssembly() + .GetManifestResourceStream("Fusion.Resources.Api.Data.personnel-import-template.xlsx"); using var memoryStream = new MemoryStream(); if (templateFile == null) @@ -117,6 +121,7 @@ public class ExcelHeader /// public int ColIndex { get; set; } } + public class ExcelDataRow { /// @@ -146,10 +151,14 @@ public class ExcelParserMessage /// public string Cell { get; set; } = null!; - public enum ExcelParserMessageLevel { Information, Warning, Error } - + public enum ExcelParserMessageLevel + { + Information, + Warning, + Error + } } #endregion } -} +} \ No newline at end of file