| | | 1 | | using Microsoft.AspNetCore.Http.HttpResults; |
| | | 2 | | using pva.SuperV.Engine.Exceptions; |
| | | 3 | | using pva.SuperV.Model.HistoryRepositories; |
| | | 4 | | using pva.SuperV.Model.Services; |
| | | 5 | | |
| | | 6 | | namespace pva.SuperV.Api.Routes.HistoryRepositories |
| | | 7 | | { |
| | | 8 | | internal static class CreateHistoryRepository |
| | | 9 | | { |
| | | 10 | | internal static async Task<Results<Created<HistoryRepositoryModel>, NotFound<string>, BadRequest<string>>> |
| | | 11 | | Handle(IHistoryRepositoryService historyRepositoryService, string projectId, HistoryRepositoryModel historyR |
| | 4 | 12 | | { |
| | | 13 | | try |
| | 4 | 14 | | { |
| | 4 | 15 | | HistoryRepositoryModel createdHistoryRepository = await historyRepositoryService.CreateHistoryRepository |
| | 2 | 16 | | return TypedResults.Created<HistoryRepositoryModel>($"/history-repositories/{projectId}/{createdHistoryR |
| | | 17 | | } |
| | 1 | 18 | | catch (UnknownEntityException e) |
| | 1 | 19 | | { |
| | 1 | 20 | | return TypedResults.NotFound(e.Message); |
| | | 21 | | } |
| | 1 | 22 | | catch (SuperVException e) |
| | 1 | 23 | | { |
| | 1 | 24 | | return TypedResults.BadRequest(e.Message); |
| | | 25 | | } |
| | 4 | 26 | | } |
| | | 27 | | } |
| | | 28 | | } |