2024-10-06 00:43:09 +02:00
|
|
|
using Microsoft.AspNetCore.Authentication.JwtBearer;
|
|
|
|
|
using Microsoft.AspNetCore.Authorization;
|
|
|
|
|
using Microsoft.AspNetCore.Http;
|
|
|
|
|
using Microsoft.AspNetCore.Mvc;
|
|
|
|
|
using WatchIt.Common.Model.Roles;
|
|
|
|
|
using WatchIt.WebAPI.Services.Controllers.Roles;
|
|
|
|
|
|
|
|
|
|
namespace WatchIt.WebAPI.Controllers;
|
|
|
|
|
|
|
|
|
|
[ApiController]
|
2024-10-06 01:12:02 +02:00
|
|
|
[Route("roles")]
|
2024-10-06 00:43:09 +02:00
|
|
|
public class RolesController : ControllerBase
|
|
|
|
|
{
|
|
|
|
|
#region SERVICES
|
|
|
|
|
|
|
|
|
|
private readonly IRolesControllerService _rolesControllerService;
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#region CONSTRUCTORS
|
|
|
|
|
|
|
|
|
|
public RolesController(IRolesControllerService rolesControllerService)
|
|
|
|
|
{
|
|
|
|
|
_rolesControllerService = rolesControllerService;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#region METHODS
|
|
|
|
|
|
|
|
|
|
#region Actor
|
|
|
|
|
|
2024-10-06 22:02:13 +02:00
|
|
|
[HttpGet("actor/{id}")]
|
|
|
|
|
[AllowAnonymous]
|
|
|
|
|
[ProducesResponseType(typeof(IEnumerable<ActorRoleResponse>), StatusCodes.Status200OK)]
|
|
|
|
|
public async Task<ActionResult> GetActorRole([FromRoute]Guid id) => await _rolesControllerService.GetActorRole(id);
|
|
|
|
|
|
|
|
|
|
[HttpPut("actor/{id}")]
|
|
|
|
|
[Authorize(AuthenticationSchemes = JwtBearerDefaults.AuthenticationScheme)]
|
|
|
|
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
|
|
|
|
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
|
|
|
|
[ProducesResponseType(typeof(void), StatusCodes.Status401Unauthorized)]
|
|
|
|
|
[ProducesResponseType(typeof(void), StatusCodes.Status403Forbidden)]
|
|
|
|
|
[ProducesResponseType(StatusCodes.Status404NotFound)]
|
|
|
|
|
public async Task<ActionResult> PutActorRole([FromRoute]Guid id, [FromBody]ActorRoleRequest body) => await _rolesControllerService.PutActorRole(id, body);
|
|
|
|
|
|
|
|
|
|
[HttpDelete("actor/{id}")]
|
|
|
|
|
[Authorize(AuthenticationSchemes = JwtBearerDefaults.AuthenticationScheme)]
|
|
|
|
|
[ProducesResponseType(StatusCodes.Status204NoContent)]
|
|
|
|
|
[ProducesResponseType(typeof(void), StatusCodes.Status401Unauthorized)]
|
|
|
|
|
[ProducesResponseType(typeof(void), StatusCodes.Status403Forbidden)]
|
|
|
|
|
public async Task<ActionResult> DeleteActorRole([FromRoute]Guid id) => await _rolesControllerService.DeleteActorRole(id);
|
|
|
|
|
|
2024-10-06 16:41:06 +02:00
|
|
|
[HttpGet("actor/type")]
|
2024-10-06 00:43:09 +02:00
|
|
|
[AllowAnonymous]
|
2024-10-06 16:41:06 +02:00
|
|
|
[ProducesResponseType(typeof(IEnumerable<RoleTypeResponse>), StatusCodes.Status200OK)]
|
|
|
|
|
public async Task<ActionResult> GetAllActorRoleTypes(RoleTypeQueryParameters query) => await _rolesControllerService.GetAllActorRoleTypes(query);
|
2024-10-06 00:43:09 +02:00
|
|
|
|
2024-10-06 22:02:13 +02:00
|
|
|
[HttpGet("actor/type/{type_id}")]
|
2024-10-06 00:43:09 +02:00
|
|
|
[AllowAnonymous]
|
2024-10-06 16:41:06 +02:00
|
|
|
[ProducesResponseType(typeof(RoleTypeResponse), StatusCodes.Status200OK)]
|
2024-10-06 00:43:09 +02:00
|
|
|
[ProducesResponseType(StatusCodes.Status404NotFound)]
|
2024-10-06 22:02:13 +02:00
|
|
|
public async Task<ActionResult> GetActorRoleType([FromRoute(Name = "type_id")]short typeId) => await _rolesControllerService.GetActorRoleType(typeId);
|
2024-10-06 00:43:09 +02:00
|
|
|
|
2024-10-06 16:41:06 +02:00
|
|
|
[HttpPost("actor/type")]
|
2024-10-06 00:43:09 +02:00
|
|
|
[Authorize(AuthenticationSchemes = JwtBearerDefaults.AuthenticationScheme)]
|
2024-10-06 16:41:06 +02:00
|
|
|
[ProducesResponseType(typeof(RoleTypeResponse), StatusCodes.Status201Created)]
|
2024-10-06 00:43:09 +02:00
|
|
|
[ProducesResponseType(typeof(ValidationProblemDetails), StatusCodes.Status400BadRequest)]
|
|
|
|
|
[ProducesResponseType(typeof(void), StatusCodes.Status401Unauthorized)]
|
|
|
|
|
[ProducesResponseType(typeof(void), StatusCodes.Status403Forbidden)]
|
2024-10-06 16:41:06 +02:00
|
|
|
public async Task<ActionResult> PostActorRoleType([FromBody]RoleTypeRequest body) => await _rolesControllerService.PostActorRoleType(body);
|
2024-10-06 00:43:09 +02:00
|
|
|
|
2024-10-06 22:02:13 +02:00
|
|
|
[HttpDelete("actor/type/{type_id}")]
|
2024-10-06 00:43:09 +02:00
|
|
|
[Authorize(AuthenticationSchemes = JwtBearerDefaults.AuthenticationScheme)]
|
|
|
|
|
[ProducesResponseType(StatusCodes.Status204NoContent)]
|
|
|
|
|
[ProducesResponseType(typeof(void), StatusCodes.Status401Unauthorized)]
|
|
|
|
|
[ProducesResponseType(typeof(void), StatusCodes.Status403Forbidden)]
|
2024-10-06 22:02:13 +02:00
|
|
|
public async Task<ActionResult> DeleteActorRoleType([FromRoute(Name = "type_id")]short typeId) => await _rolesControllerService.DeleteActorRoleType(typeId);
|
2024-10-06 00:43:09 +02:00
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region Creator
|
|
|
|
|
|
2024-10-06 22:02:13 +02:00
|
|
|
[HttpGet("creator/{id}")]
|
|
|
|
|
[AllowAnonymous]
|
|
|
|
|
[ProducesResponseType(typeof(IEnumerable<CreatorRoleResponse>), StatusCodes.Status200OK)]
|
|
|
|
|
public async Task<ActionResult> GetCreatorRole([FromRoute]Guid id) => await _rolesControllerService.GetCreatorRole(id);
|
|
|
|
|
|
|
|
|
|
[HttpPut("creator/{id}")]
|
|
|
|
|
[Authorize(AuthenticationSchemes = JwtBearerDefaults.AuthenticationScheme)]
|
|
|
|
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
|
|
|
|
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
|
|
|
|
[ProducesResponseType(typeof(void), StatusCodes.Status401Unauthorized)]
|
|
|
|
|
[ProducesResponseType(typeof(void), StatusCodes.Status403Forbidden)]
|
|
|
|
|
[ProducesResponseType(StatusCodes.Status404NotFound)]
|
|
|
|
|
public async Task<ActionResult> PutCreatorRole([FromRoute]Guid id, [FromBody]CreatorRoleRequest body) => await _rolesControllerService.PutCreatorRole(id, body);
|
|
|
|
|
|
|
|
|
|
[HttpDelete("creator/{id}")]
|
|
|
|
|
[Authorize(AuthenticationSchemes = JwtBearerDefaults.AuthenticationScheme)]
|
|
|
|
|
[ProducesResponseType(StatusCodes.Status204NoContent)]
|
|
|
|
|
[ProducesResponseType(typeof(void), StatusCodes.Status401Unauthorized)]
|
|
|
|
|
[ProducesResponseType(typeof(void), StatusCodes.Status403Forbidden)]
|
|
|
|
|
public async Task<ActionResult> DeleteCreatorRole([FromRoute]Guid id) => await _rolesControllerService.DeleteCreatorRole(id);
|
|
|
|
|
|
2024-10-06 16:41:06 +02:00
|
|
|
[HttpGet("creator/type")]
|
2024-10-06 00:43:09 +02:00
|
|
|
[AllowAnonymous]
|
2024-10-06 16:41:06 +02:00
|
|
|
[ProducesResponseType(typeof(IEnumerable<RoleTypeResponse>), StatusCodes.Status200OK)]
|
|
|
|
|
public async Task<ActionResult> GetAllCreatorRoleTypes(RoleTypeQueryParameters query) => await _rolesControllerService.GetAllCreatorRoleTypes(query);
|
2024-10-06 00:43:09 +02:00
|
|
|
|
2024-10-06 16:41:06 +02:00
|
|
|
[HttpGet("creator/type/{id}")]
|
2024-10-06 00:43:09 +02:00
|
|
|
[AllowAnonymous]
|
2024-10-06 16:41:06 +02:00
|
|
|
[ProducesResponseType(typeof(RoleTypeResponse), StatusCodes.Status200OK)]
|
2024-10-06 00:43:09 +02:00
|
|
|
[ProducesResponseType(StatusCodes.Status404NotFound)]
|
2024-10-06 16:41:06 +02:00
|
|
|
public async Task<ActionResult> GetCreatorRoleType([FromRoute]short id) => await _rolesControllerService.GetCreatorRoleType(id);
|
2024-10-06 00:43:09 +02:00
|
|
|
|
2024-10-06 16:41:06 +02:00
|
|
|
[HttpPost("creator/type")]
|
2024-10-06 00:43:09 +02:00
|
|
|
[Authorize(AuthenticationSchemes = JwtBearerDefaults.AuthenticationScheme)]
|
2024-10-06 16:41:06 +02:00
|
|
|
[ProducesResponseType(typeof(RoleTypeResponse), StatusCodes.Status201Created)]
|
2024-10-06 00:43:09 +02:00
|
|
|
[ProducesResponseType(typeof(ValidationProblemDetails), StatusCodes.Status400BadRequest)]
|
|
|
|
|
[ProducesResponseType(typeof(void), StatusCodes.Status401Unauthorized)]
|
|
|
|
|
[ProducesResponseType(typeof(void), StatusCodes.Status403Forbidden)]
|
2024-10-06 16:41:06 +02:00
|
|
|
public async Task<ActionResult> PostCreatorRoleType([FromBody]RoleTypeRequest body) => await _rolesControllerService.PostCreatorRoleType(body);
|
2024-10-06 00:43:09 +02:00
|
|
|
|
2024-10-06 16:41:06 +02:00
|
|
|
[HttpDelete("creator/type/{id}")]
|
2024-10-06 00:43:09 +02:00
|
|
|
[Authorize(AuthenticationSchemes = JwtBearerDefaults.AuthenticationScheme)]
|
|
|
|
|
[ProducesResponseType(StatusCodes.Status204NoContent)]
|
|
|
|
|
[ProducesResponseType(typeof(void), StatusCodes.Status401Unauthorized)]
|
|
|
|
|
[ProducesResponseType(typeof(void), StatusCodes.Status403Forbidden)]
|
2024-10-06 16:41:06 +02:00
|
|
|
public async Task<ActionResult> DeleteCreatorRoleType([FromRoute]short id) => await _rolesControllerService.DeleteCreatorRoleType(id);
|
2024-10-06 00:43:09 +02:00
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
}
|