view rank get endpoint for movies added
This commit is contained in:
@@ -11,18 +11,41 @@ namespace WatchIt.WebAPI.Controllers;
|
||||
|
||||
[ApiController]
|
||||
[Route("movies")]
|
||||
public class MoviesController(IMoviesControllerService moviesControllerService) : ControllerBase
|
||||
public class MoviesController : ControllerBase
|
||||
{
|
||||
#region SERVICES
|
||||
|
||||
private readonly IMoviesControllerService _moviesControllerService;
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
#region CONSTRUCTORS
|
||||
|
||||
public MoviesController(IMoviesControllerService moviesControllerService)
|
||||
{
|
||||
_moviesControllerService = moviesControllerService;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
#region METHODS
|
||||
|
||||
#region Main
|
||||
|
||||
[HttpGet]
|
||||
[AllowAnonymous]
|
||||
[ProducesResponseType(typeof(IEnumerable<MovieResponse>), StatusCodes.Status200OK)]
|
||||
public async Task<ActionResult> GetAll(MovieQueryParameters query) => await moviesControllerService.GetAll(query);
|
||||
public async Task<ActionResult> GetAllMovies(MovieQueryParameters query) => await _moviesControllerService.GetAllMovies(query);
|
||||
|
||||
[HttpGet("{id}")]
|
||||
[AllowAnonymous]
|
||||
[ProducesResponseType(typeof(MovieResponse), StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(StatusCodes.Status404NotFound)]
|
||||
public async Task<ActionResult> Get([FromRoute]long id) => await moviesControllerService.Get(id);
|
||||
public async Task<ActionResult> GetMovie([FromRoute] long id) => await _moviesControllerService.GetMovie(id);
|
||||
|
||||
[HttpPost]
|
||||
[Authorize(AuthenticationSchemes = JwtBearerDefaults.AuthenticationScheme)]
|
||||
@@ -30,7 +53,7 @@ public class MoviesController(IMoviesControllerService moviesControllerService)
|
||||
[ProducesResponseType(typeof(ValidationProblemDetails), StatusCodes.Status400BadRequest)]
|
||||
[ProducesResponseType(typeof(void), StatusCodes.Status401Unauthorized)]
|
||||
[ProducesResponseType(typeof(void), StatusCodes.Status403Forbidden)]
|
||||
public async Task<ActionResult> Post([FromBody]MovieRequest body) => await moviesControllerService.Post(body);
|
||||
public async Task<ActionResult> PostMovie([FromBody] MovieRequest body) => await _moviesControllerService.PostMovie(body);
|
||||
|
||||
[HttpPut("{id}")]
|
||||
[Authorize(AuthenticationSchemes = JwtBearerDefaults.AuthenticationScheme)]
|
||||
@@ -38,12 +61,26 @@ public class MoviesController(IMoviesControllerService moviesControllerService)
|
||||
[ProducesResponseType(typeof(ValidationProblemDetails), StatusCodes.Status400BadRequest)]
|
||||
[ProducesResponseType(typeof(void), StatusCodes.Status401Unauthorized)]
|
||||
[ProducesResponseType(typeof(void), StatusCodes.Status403Forbidden)]
|
||||
public async Task<ActionResult> Put([FromRoute]long id, [FromBody]MovieRequest body) => await moviesControllerService.Put(id, body);
|
||||
public async Task<ActionResult> PutMovie([FromRoute] long id, [FromBody]MovieRequest body) => await _moviesControllerService.PutMovie(id, body);
|
||||
|
||||
[HttpDelete("{id}")]
|
||||
[Authorize(AuthenticationSchemes = JwtBearerDefaults.AuthenticationScheme)]
|
||||
[ProducesResponseType(typeof(void), StatusCodes.Status204NoContent)]
|
||||
[ProducesResponseType(typeof(void), StatusCodes.Status401Unauthorized)]
|
||||
[ProducesResponseType(typeof(void), StatusCodes.Status403Forbidden)]
|
||||
public async Task<ActionResult> Delete([FromRoute] long id) => await moviesControllerService.Delete(id);
|
||||
public async Task<ActionResult> DeleteMovie([FromRoute] long id) => await _moviesControllerService.DeleteMovie(id);
|
||||
|
||||
#endregion
|
||||
|
||||
#region View count
|
||||
|
||||
[HttpGet("view")]
|
||||
[AllowAnonymous]
|
||||
[ProducesResponseType(typeof(IEnumerable<MovieResponse>), StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
||||
public async Task<ActionResult> GetMoviesViewRank([FromQuery] int first = 5, [FromQuery] int days = 7) => await _moviesControllerService.GetMoviesViewRank(first, days);
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
}
|
||||
Reference in New Issue
Block a user