person controller finished

This commit is contained in:
2024-10-03 16:18:17 +02:00
Unverified
parent 9a9e29ecf4
commit 4f16596ea3
14 changed files with 379 additions and 2 deletions

View File

@@ -1,4 +1,9 @@
using Microsoft.AspNetCore.Authentication.JwtBearer;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using WatchIt.Common.Model.Persons;
using WatchIt.WebAPI.Services.Controllers.Persons;
namespace WatchIt.WebAPI.Controllers;
@@ -7,8 +12,73 @@ namespace WatchIt.WebAPI.Controllers;
public class PersonsController : ControllerBase
{
#region SERVICES
private readonly IPersonsControllerService _personsControllerService;
#endregion
#region CONSTRUCTORS
public PersonsController(IPersonsControllerService personsControllerService)
{
_personsControllerService = personsControllerService;
}
#endregion
#region METHODS
#region Main
[HttpGet]
[AllowAnonymous]
[ProducesResponseType(typeof(IEnumerable<PersonResponse>), StatusCodes.Status200OK)]
public async Task<ActionResult> GetAllMovies(PersonQueryParameters query) => await _personsControllerService.GetAllPersons(query);
[HttpGet("{id}")]
[AllowAnonymous]
[ProducesResponseType(typeof(PersonResponse), StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status404NotFound)]
public async Task<ActionResult> GetMovie([FromRoute] long id) => await _personsControllerService.GetPerson(id);
[HttpPost]
[Authorize(AuthenticationSchemes = JwtBearerDefaults.AuthenticationScheme)]
[ProducesResponseType(typeof(PersonResponse), StatusCodes.Status201Created)]
[ProducesResponseType(typeof(ValidationProblemDetails), StatusCodes.Status400BadRequest)]
[ProducesResponseType(typeof(void), StatusCodes.Status401Unauthorized)]
[ProducesResponseType(typeof(void), StatusCodes.Status403Forbidden)]
public async Task<ActionResult> PostMovie([FromBody] PersonRequest body) => await _personsControllerService.PostPerson(body);
[HttpPut("{id}")]
[Authorize(AuthenticationSchemes = JwtBearerDefaults.AuthenticationScheme)]
[ProducesResponseType(typeof(void), StatusCodes.Status200OK)]
[ProducesResponseType(typeof(ValidationProblemDetails), StatusCodes.Status400BadRequest)]
[ProducesResponseType(typeof(void), StatusCodes.Status401Unauthorized)]
[ProducesResponseType(typeof(void), StatusCodes.Status403Forbidden)]
public async Task<ActionResult> PutMovie([FromRoute] long id, [FromBody]PersonRequest body) => await _personsControllerService.PutPerson(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> DeleteMovie([FromRoute] long id) => await _personsControllerService.DeletePerson(id);
#endregion
#region View count
[HttpGet("view")]
[AllowAnonymous]
[ProducesResponseType(typeof(IEnumerable<PersonResponse>), StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status400BadRequest)]
public async Task<ActionResult> GetMoviesViewRank([FromQuery] int first = 5, [FromQuery] int days = 7) => await _personsControllerService.GetPersonsViewRank(first, days);
#endregion
#endregion
}

View File

@@ -17,6 +17,7 @@
<ProjectReference Include="..\WatchIt.WebAPI.Services\WatchIt.WebAPI.Services.Controllers\WatchIt.WebAPI.Services.Controllers.Genres\WatchIt.WebAPI.Services.Controllers.Genres.csproj" />
<ProjectReference Include="..\WatchIt.WebAPI.Services\WatchIt.WebAPI.Services.Controllers\WatchIt.WebAPI.Services.Controllers.Media\WatchIt.WebAPI.Services.Controllers.Media.csproj" />
<ProjectReference Include="..\WatchIt.WebAPI.Services\WatchIt.WebAPI.Services.Controllers\WatchIt.WebAPI.Services.Controllers.Movies\WatchIt.WebAPI.Services.Controllers.Movies.csproj" />
<ProjectReference Include="..\WatchIt.WebAPI.Services\WatchIt.WebAPI.Services.Controllers\WatchIt.WebAPI.Services.Controllers.Persons\WatchIt.WebAPI.Services.Controllers.Persons.csproj" />
<ProjectReference Include="..\WatchIt.WebAPI.Services\WatchIt.WebAPI.Services.Controllers\WatchIt.WebAPI.Services.Controllers.Photos\WatchIt.WebAPI.Services.Controllers.Photos.csproj" />
<ProjectReference Include="..\WatchIt.WebAPI.Services\WatchIt.WebAPI.Services.Controllers\WatchIt.WebAPI.Services.Controllers.Series\WatchIt.WebAPI.Services.Controllers.Series.csproj" />
</ItemGroup>