| | | 1 | | using Microsoft.AspNetCore.Http.HttpResults; |
| | | 2 | | using pva.SuperV.Engine.Exceptions; |
| | | 3 | | using pva.SuperV.Model.FieldDefinitions; |
| | | 4 | | using pva.SuperV.Model.Services; |
| | | 5 | | |
| | | 6 | | namespace pva.SuperV.Api.Routes.FieldDefinitions |
| | | 7 | | { |
| | | 8 | | internal static class GetFieldDefinition |
| | | 9 | | { |
| | | 10 | | internal static async Task<Results<Ok<FieldDefinitionModel>, NotFound<string>, BadRequest<string>>> |
| | | 11 | | Handle(IFieldDefinitionService fieldDefinitionService, string projectId, string className, string fieldName) |
| | 13 | 12 | | { |
| | | 13 | | try |
| | 13 | 14 | | { |
| | 13 | 15 | | FieldDefinitionModel fieldDefinitionModel = await fieldDefinitionService.GetFieldAsync(projectId, classN |
| | 12 | 16 | | return TypedResults.Ok<FieldDefinitionModel>(fieldDefinitionModel); |
| | | 17 | | } |
| | 1 | 18 | | catch (UnknownEntityException e) |
| | 1 | 19 | | { |
| | 1 | 20 | | return TypedResults.NotFound(e.Message); |
| | | 21 | | } |
| | 0 | 22 | | catch (SuperVException e) |
| | 0 | 23 | | { |
| | 0 | 24 | | return TypedResults.BadRequest(e.Message); |
| | | 25 | | } |
| | 13 | 26 | | } |
| | | 27 | | } |
| | | 28 | | } |