| | | 1 | | |
| | | 2 | | using Microsoft.AspNetCore.Http.HttpResults; |
| | | 3 | | using pva.SuperV.Engine.Exceptions; |
| | | 4 | | using pva.SuperV.Model.Services; |
| | | 5 | | |
| | | 6 | | namespace pva.SuperV.Api.Routes.Projects |
| | | 7 | | { |
| | | 8 | | internal static class LoadProjectInstances |
| | | 9 | | { |
| | | 10 | | internal static async Task<Results<Ok, NotFound<string>, BadRequest<string>>> |
| | | 11 | | Handle(IProjectService projectService, string projectId, byte[] fileData) |
| | 3 | 12 | | { |
| | | 13 | | try |
| | 3 | 14 | | { |
| | 3 | 15 | | using StreamReader reader = new(new MemoryStream(fileData), System.Text.Encoding.UTF8); |
| | 3 | 16 | | await projectService.LoadProjectInstancesAsync(projectId, reader); |
| | 1 | 17 | | return TypedResults.Ok(); |
| | | 18 | | } |
| | 1 | 19 | | catch (UnknownEntityException e) |
| | 1 | 20 | | { |
| | 1 | 21 | | return TypedResults.NotFound(e.Message); |
| | | 22 | | } |
| | 1 | 23 | | catch (SuperVException e) |
| | 1 | 24 | | { |
| | 1 | 25 | | return TypedResults.BadRequest(e.Message); |
| | | 26 | | } |
| | 3 | 27 | | } |
| | | 28 | | } |
| | | 29 | | } |