| | | 1 | | using Microsoft.AspNetCore.Mvc; |
| | | 2 | | using pva.SuperV.Model; |
| | | 3 | | using pva.SuperV.Model.Classes; |
| | | 4 | | using pva.SuperV.Model.Services; |
| | | 5 | | using System.ComponentModel; |
| | | 6 | | |
| | | 7 | | namespace pva.SuperV.Api.Routes.Classes |
| | | 8 | | { |
| | | 9 | | public static class ClassEndpoints |
| | | 10 | | { |
| | | 11 | | public static WebApplication MapClassEndpoints(this WebApplication app) |
| | 131 | 12 | | { |
| | 131 | 13 | | RouteGroupBuilder classesApi = app.MapGroup("/classes"); |
| | 131 | 14 | | classesApi.MapGet("/{projectId}", |
| | 131 | 15 | | async (IClassService classService, |
| | 131 | 16 | | [Description("ID of project")] string projectId) |
| | 2 | 17 | | => await GetClasses.Handle(classService, projectId)) |
| | 131 | 18 | | .WithName("GetClasses") |
| | 131 | 19 | | .WithDisplayName("GetClasses") |
| | 131 | 20 | | .WithSummary("Gets the list of available classes in a project") |
| | 131 | 21 | | .WithDescription("Gets the list of available classes in a project") |
| | 131 | 22 | | .Produces<List<ClassModel>>(StatusCodes.Status200OK) |
| | 131 | 23 | | .Produces<string>(StatusCodes.Status404NotFound) |
| | 131 | 24 | | .Produces<string>(StatusCodes.Status400BadRequest); |
| | | 25 | | |
| | 131 | 26 | | classesApi.MapPost("/{projectId}/search", |
| | 131 | 27 | | async (IClassService classService, |
| | 131 | 28 | | [Description("ID of project")] string projectId, |
| | 131 | 29 | | [FromBody] ClassPagedSearchRequest search) |
| | 1 | 30 | | => await SearchClasses.Handle(classService, projectId, search)) |
| | 131 | 31 | | .WithName("SearchClasses") |
| | 131 | 32 | | .WithDisplayName("SearchClasses") |
| | 131 | 33 | | .WithSummary("Searches the list of available classes in a project") |
| | 131 | 34 | | .WithDescription("Searches the list of available classes in a project") |
| | 131 | 35 | | .Produces<PagedSearchResult<ClassModel>>(StatusCodes.Status200OK) |
| | 131 | 36 | | .Produces<string>(StatusCodes.Status404NotFound) |
| | 131 | 37 | | .Produces<string>(StatusCodes.Status400BadRequest); |
| | | 38 | | |
| | 131 | 39 | | classesApi.MapGet("/{projectId}/{className}", |
| | 131 | 40 | | async (IClassService classService, |
| | 131 | 41 | | [Description("ID of project")] string projectId, |
| | 131 | 42 | | [Description("Name of class")] string className) |
| | 2 | 43 | | => await GetClass.Handle(classService, projectId, className)) |
| | 131 | 44 | | .WithName("GetClass") |
| | 131 | 45 | | .WithDisplayName("GetClass") |
| | 131 | 46 | | .WithSummary("Gets a class of a project by its name") |
| | 131 | 47 | | .WithDescription("Gets a class of a project by its name") |
| | 131 | 48 | | .Produces<ClassModel>(StatusCodes.Status200OK) |
| | 131 | 49 | | .Produces<string>(StatusCodes.Status404NotFound) |
| | 131 | 50 | | .Produces<string>(StatusCodes.Status400BadRequest); |
| | | 51 | | |
| | 131 | 52 | | classesApi.MapPost("/{wipProjectId}", |
| | 131 | 53 | | async (IClassService classService, |
| | 131 | 54 | | [Description("ID of WIP project")] string wipProjectId, |
| | 131 | 55 | | [Description("Class creation request")][FromBody] ClassModel createRequest) |
| | 6 | 56 | | => await CreateClass.Handle(classService, wipProjectId, createRequest)) |
| | 131 | 57 | | .WithName("CreateClass") |
| | 131 | 58 | | .WithDisplayName("CreateClass") |
| | 131 | 59 | | .WithSummary("Creates a class in a WIP project") |
| | 131 | 60 | | .WithDescription("Creates a class in a WIP project") |
| | 131 | 61 | | .Produces<ClassModel>(StatusCodes.Status201Created) |
| | 131 | 62 | | .Produces<string>(StatusCodes.Status404NotFound) |
| | 131 | 63 | | .Produces<string>(StatusCodes.Status400BadRequest); |
| | | 64 | | |
| | 131 | 65 | | classesApi.MapPut("/{wipProjectId}/{className}", |
| | 131 | 66 | | async (IClassService classService, |
| | 131 | 67 | | [Description("ID of WIP project")] string wipProjectId, |
| | 131 | 68 | | [Description("Name of class to be updated")] string className, |
| | 131 | 69 | | [Description("Class update request")][FromBody] ClassModel createRequest) |
| | 3 | 70 | | => await UpdateClass.Handle(classService, wipProjectId, className, createRequest)) |
| | 131 | 71 | | .WithName("UpdateClass") |
| | 131 | 72 | | .WithDisplayName("UpdateClass") |
| | 131 | 73 | | .WithSummary("Updates a class in a WIP project") |
| | 131 | 74 | | .WithDescription("Updates a class in a WIP project") |
| | 131 | 75 | | .Produces<ClassModel>(StatusCodes.Status200OK) |
| | 131 | 76 | | .Produces<string>(StatusCodes.Status404NotFound) |
| | 131 | 77 | | .Produces<string>(StatusCodes.Status400BadRequest); |
| | | 78 | | |
| | 131 | 79 | | classesApi.MapDelete("/{wipProjectId}/{className}", |
| | 131 | 80 | | async (IClassService classService, |
| | 131 | 81 | | [Description("ID of WIP project")] string wipProjectId, |
| | 131 | 82 | | [Description("Name of class")] string className) |
| | 3 | 83 | | => await DeleteClass.Handle(classService, wipProjectId, className)) |
| | 131 | 84 | | .WithName("DeleteClass") |
| | 131 | 85 | | .WithDisplayName("DeleteClass") |
| | 131 | 86 | | .WithSummary("Deletes a class of a project by its name") |
| | 131 | 87 | | .WithDescription("Deletes a class of a WIP project by its name") |
| | 131 | 88 | | .Produces(StatusCodes.Status204NoContent) |
| | 131 | 89 | | .Produces<string>(StatusCodes.Status404NotFound) |
| | 131 | 90 | | .Produces<string>(StatusCodes.Status400BadRequest); |
| | | 91 | | |
| | 131 | 92 | | return app; |
| | 131 | 93 | | } |
| | | 94 | | } |
| | | 95 | | } |