| | | 1 | | using Microsoft.AspNetCore.Mvc; |
| | | 2 | | using pva.SuperV.Model; |
| | | 3 | | using pva.SuperV.Model.FieldFormatters; |
| | | 4 | | using pva.SuperV.Model.Services; |
| | | 5 | | using System.ComponentModel; |
| | | 6 | | |
| | | 7 | | namespace pva.SuperV.Api.Routes.FieldFormatters |
| | | 8 | | { |
| | | 9 | | public static class FieldFormattersEndpoints |
| | | 10 | | { |
| | | 11 | | public static WebApplication MapFieldFormatterEndpoints(this WebApplication app) |
| | 131 | 12 | | { |
| | 131 | 13 | | RouteGroupBuilder fieldFormattersApi = app.MapGroup("/field-formatters"); |
| | 131 | 14 | | fieldFormattersApi.MapGet("/", |
| | 131 | 15 | | async (IFieldFormatterService fieldFormatterService) |
| | 1 | 16 | | => await GetFieldFormatterTypes.Handle(fieldFormatterService)) |
| | 131 | 17 | | .WithName("GetFieldFormatterTypes") |
| | 131 | 18 | | .WithDisplayName("GetFieldFormatterTypes") |
| | 131 | 19 | | .WithSummary("Gets the list of available field formatter types") |
| | 131 | 20 | | .WithDescription("Gets the list of available field formatter types") |
| | 131 | 21 | | .Produces<List<string>>(StatusCodes.Status200OK); |
| | | 22 | | |
| | 131 | 23 | | fieldFormattersApi.MapGet("/{projectId}", |
| | 131 | 24 | | async (IFieldFormatterService fieldFormatterService, |
| | 131 | 25 | | [Description("ID of project")] string projectId) |
| | 2 | 26 | | => await GetFieldFormatters.Handle(fieldFormatterService, projectId)) |
| | 131 | 27 | | .WithName("GetFieldFormatters") |
| | 131 | 28 | | .WithDisplayName("GetFieldFormatters") |
| | 131 | 29 | | .WithSummary("Gets the list of field formatters of project") |
| | 131 | 30 | | .WithDescription("Gets the list of field formatters of project") |
| | 131 | 31 | | .Produces<List<FieldFormatterModel>>(StatusCodes.Status200OK) |
| | 131 | 32 | | .Produces<string>(StatusCodes.Status404NotFound); |
| | | 33 | | |
| | 131 | 34 | | fieldFormattersApi.MapPost("/{projectId}/search", |
| | 131 | 35 | | async (IFieldFormatterService fieldFormatterService, |
| | 131 | 36 | | [Description("ID of project")] string projectId, |
| | 131 | 37 | | [FromBody] FieldFormatterPagedSearchRequest search) |
| | 1 | 38 | | => await SearchFieldFormatters.Handle(fieldFormatterService, projectId, search)) |
| | 131 | 39 | | .WithName("SearchFieldFormatterTypes") |
| | 131 | 40 | | .WithDisplayName("SearchFieldFormatterTypes") |
| | 131 | 41 | | .WithSummary("Searches the list of available field formatter types") |
| | 131 | 42 | | .WithDescription("Searches the list of available field formatter types") |
| | 131 | 43 | | .Produces<PagedSearchResult<FieldFormatterModel>>(StatusCodes.Status200OK); |
| | | 44 | | |
| | 131 | 45 | | fieldFormattersApi.MapGet("/{projectId}/{fieldFormatterName}", |
| | 131 | 46 | | async (IFieldFormatterService fieldFormatterService, |
| | 131 | 47 | | [Description("ID of project")] string projectId, |
| | 131 | 48 | | [Description("Name of field formatter")] string fieldFormatterName) |
| | 2 | 49 | | => await GetFieldFormatter.Handle(fieldFormatterService, projectId, fieldFormatterName)) |
| | 131 | 50 | | .WithName("GetFieldFormatter") |
| | 131 | 51 | | .WithDisplayName("GetFieldFormatter") |
| | 131 | 52 | | .WithSummary("Gets a field formatter of project") |
| | 131 | 53 | | .WithDescription("Gets a field formatter of project") |
| | 131 | 54 | | .Produces<FieldFormatterModel>(StatusCodes.Status200OK) |
| | 131 | 55 | | .Produces<string>(StatusCodes.Status404NotFound) |
| | 131 | 56 | | .Produces<string>(StatusCodes.Status400BadRequest); |
| | | 57 | | |
| | 131 | 58 | | fieldFormattersApi.MapPost("/{wipProjectId}", |
| | 131 | 59 | | async (IFieldFormatterService fieldFormatterService, HttpContext context, |
| | 131 | 60 | | [Description("ID of WIP project")] string wipProjectId, |
| | 131 | 61 | | [Description("Field formatter creation request")][FromBody] CreateFieldFormatterRequest createRequest) |
| | 5 | 62 | | => await CreateFieldFormatter.Handle(fieldFormatterService, wipProjectId, createRequest)) |
| | 131 | 63 | | .WithName("CreateFieldFormatter") |
| | 131 | 64 | | .WithDisplayName("CreateFieldFormatter") |
| | 131 | 65 | | .WithSummary("Creates a field formatter in a WIP project") |
| | 131 | 66 | | .WithDescription("Creates a field formatter in a WIP project") |
| | 131 | 67 | | .Produces<FieldFormatterModel>(StatusCodes.Status201Created) |
| | 131 | 68 | | .Produces<string>(StatusCodes.Status404NotFound) |
| | 131 | 69 | | .Produces<string>(StatusCodes.Status400BadRequest); |
| | | 70 | | |
| | 131 | 71 | | fieldFormattersApi.MapPut("/{wipProjectId}/{fieldFormatterName}", |
| | 131 | 72 | | async (IFieldFormatterService fieldFormatterService, HttpContext context, |
| | 131 | 73 | | [Description("ID of WIP project")] string wipProjectId, |
| | 131 | 74 | | [Description("Field formatter name")] string fieldFormatterName, |
| | 131 | 75 | | [Description("Field formatter update model")][FromBody] FieldFormatterModel fieldFormatterModel) |
| | 3 | 76 | | => await UpdateFieldFormatter.Handle(fieldFormatterService, wipProjectId, fieldFormatterName, fieldF |
| | 131 | 77 | | .WithName("UpdateFieldFormatter") |
| | 131 | 78 | | .WithDisplayName("UpdateFieldFormatter") |
| | 131 | 79 | | .WithSummary("Updates a field formatter in a WIP project") |
| | 131 | 80 | | .WithDescription("Updates a field formatter in a WIP project") |
| | 131 | 81 | | .Produces<FieldFormatterModel>(StatusCodes.Status200OK) |
| | 131 | 82 | | .Produces<string>(StatusCodes.Status404NotFound) |
| | 131 | 83 | | .Produces<string>(StatusCodes.Status400BadRequest); |
| | | 84 | | |
| | 131 | 85 | | fieldFormattersApi.MapDelete("/{wipProjectId}/{fieldFormatterName}", |
| | 131 | 86 | | async (IFieldFormatterService fieldFormatterService, |
| | 131 | 87 | | [Description("ID of WUP project")] string wipProjectId, |
| | 131 | 88 | | [Description("Name of field formatter")] string fieldFormatterName) |
| | 3 | 89 | | => await DeleteFieldFormatter.Handle(fieldFormatterService, wipProjectId, fieldFormatterName)) |
| | 131 | 90 | | .WithName("DeleteFieldFormatter") |
| | 131 | 91 | | .WithDisplayName("DeleteFieldFormatter") |
| | 131 | 92 | | .WithSummary("Deletes a field formatter from a WIP project") |
| | 131 | 93 | | .WithDescription("Deletes a field formatter from a WIP project") |
| | 131 | 94 | | .Produces(StatusCodes.Status204NoContent) |
| | 131 | 95 | | .Produces<string>(StatusCodes.Status404NotFound) |
| | 131 | 96 | | .Produces<string>(StatusCodes.Status400BadRequest); |
| | | 97 | | |
| | 131 | 98 | | return app; |
| | 131 | 99 | | } |
| | | 100 | | } |
| | | 101 | | } |