genre page added

This commit is contained in:
2024-11-08 17:53:23 +01:00
Unverified
parent 9f2ccadff7
commit 2d5b996337
20 changed files with 870 additions and 355 deletions

View File

@@ -2,6 +2,7 @@
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using WatchIt.Common.Model.Genres;
using WatchIt.Common.Model.Media;
using WatchIt.WebAPI.Services.Controllers.Genres;
namespace WatchIt.WebAPI.Controllers;
@@ -10,16 +11,20 @@ namespace WatchIt.WebAPI.Controllers;
[Route("genres")]
public class GenresController(IGenresControllerService genresControllerService) : ControllerBase
{
#region METHODS
#region Main
[HttpGet]
[AllowAnonymous]
[ProducesResponseType(typeof(IEnumerable<GenreResponse>), StatusCodes.Status200OK)]
public async Task<ActionResult> GetAll(GenreQueryParameters query) => await genresControllerService.GetAll(query);
public async Task<ActionResult> GetGenres(GenreQueryParameters query) => await genresControllerService.GetGenres(query);
[HttpGet("{id}")]
[AllowAnonymous]
[ProducesResponseType(typeof(GenreResponse), StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status404NotFound)]
public async Task<ActionResult> Get([FromRoute]short id) => await genresControllerService.Get(id);
public async Task<ActionResult> GetGenre([FromRoute]short id) => await genresControllerService.GetGenre(id);
[HttpPost]
[Authorize]
@@ -27,7 +32,7 @@ public class GenresController(IGenresControllerService genresControllerService)
[ProducesResponseType(typeof(ValidationProblemDetails), StatusCodes.Status400BadRequest)]
[ProducesResponseType(typeof(void), StatusCodes.Status401Unauthorized)]
[ProducesResponseType(typeof(void), StatusCodes.Status403Forbidden)]
public async Task<ActionResult> Post([FromBody]GenreRequest body) => await genresControllerService.Post(body);
public async Task<ActionResult> PostGenre([FromBody]GenreRequest body) => await genresControllerService.PostGenre(body);
[HttpPut("{id}")]
[Authorize]
@@ -35,7 +40,7 @@ public class GenresController(IGenresControllerService genresControllerService)
[ProducesResponseType(typeof(void), StatusCodes.Status401Unauthorized)]
[ProducesResponseType(typeof(void), StatusCodes.Status403Forbidden)]
[ProducesResponseType(StatusCodes.Status404NotFound)]
public async Task<ActionResult> Put([FromRoute]short id, [FromBody]GenreRequest body) => await genresControllerService.Put(id, body);
public async Task<ActionResult> PutGenre([FromRoute]short id, [FromBody]GenreRequest body) => await genresControllerService.PutGenre(id, body);
[HttpDelete("{id}")]
[Authorize]
@@ -44,5 +49,19 @@ public class GenresController(IGenresControllerService genresControllerService)
[ProducesResponseType(typeof(void), StatusCodes.Status401Unauthorized)]
[ProducesResponseType(typeof(void), StatusCodes.Status403Forbidden)]
[ProducesResponseType(StatusCodes.Status404NotFound)]
public async Task<ActionResult> Delete([FromRoute]short id) => await genresControllerService.Delete(id);
public async Task<ActionResult> DeleteGenre([FromRoute]short id) => await genresControllerService.DeleteGenre(id);
#endregion
#region Media
[HttpGet("{id}/media")]
[AllowAnonymous]
[ProducesResponseType(typeof(IEnumerable<MediaResponse>), StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status404NotFound)]
public async Task<ActionResult> GetGenreMedia([FromRoute]short id, MediaQueryParameters query) => await genresControllerService.GetGenreMedia(id, query);
#endregion
#endregion
}