Files

66 lines
2.3 KiB
C#
Raw Permalink Normal View History

2024-10-05 09:12:28 +02:00
using Microsoft.AspNetCore.Authentication.JwtBearer;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using WatchIt.Common.Model.Genders;
using WatchIt.WebAPI.Services.Controllers.Genders;
namespace WatchIt.WebAPI.Controllers;
[ApiController]
[Route("genders")]
public class GendersController : ControllerBase
{
#region SERVICES
private readonly IGendersControllerService _gendersControllerService;
#endregion
#region CONSTRUCTORS
public GendersController(IGendersControllerService gendersControllerService)
{
_gendersControllerService = gendersControllerService;
}
#endregion
#region METHODS
#region Main
[HttpGet]
[AllowAnonymous]
[ProducesResponseType(typeof(IEnumerable<GenderResponse>), StatusCodes.Status200OK)]
public async Task<ActionResult> GetAllGenders(GenderQueryParameters query) => await _gendersControllerService.GetAllGenders(query);
[HttpGet("{id}")]
[AllowAnonymous]
[ProducesResponseType(typeof(GenderResponse), StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status404NotFound)]
public async Task<ActionResult> GetGender([FromRoute]short id) => await _gendersControllerService.GetGender(id);
[HttpPost]
[Authorize(AuthenticationSchemes = JwtBearerDefaults.AuthenticationScheme)]
[ProducesResponseType(typeof(GenderResponse), StatusCodes.Status201Created)]
[ProducesResponseType(typeof(ValidationProblemDetails), StatusCodes.Status400BadRequest)]
[ProducesResponseType(typeof(void), StatusCodes.Status401Unauthorized)]
[ProducesResponseType(typeof(void), StatusCodes.Status403Forbidden)]
public async Task<ActionResult> PostGender([FromBody]GenderRequest body) => await _gendersControllerService.PostGender(body);
[HttpDelete("{id}")]
[Authorize(AuthenticationSchemes = JwtBearerDefaults.AuthenticationScheme)]
2024-10-06 00:43:09 +02:00
[ProducesResponseType(StatusCodes.Status204NoContent)]
2024-10-05 09:12:28 +02:00
[ProducesResponseType(typeof(void), StatusCodes.Status401Unauthorized)]
[ProducesResponseType(typeof(void), StatusCodes.Status403Forbidden)]
public async Task<ActionResult> DeleteGender([FromRoute]short id) => await _gendersControllerService.DeleteGender(id);
#endregion
#endregion
}