You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
45 lines
1.6 KiB
45 lines
1.6 KiB
using Microsoft.AspNetCore.Mvc;
|
|
using Server.Dto.Response;
|
|
using Asp.Versioning;
|
|
using Server.IServices;
|
|
using Shared.Criteria;
|
|
|
|
namespace Server.Controller.v1;
|
|
|
|
[ApiController]
|
|
[ApiVersion("1.0")]
|
|
[Route("api/v{version:apiVersion}/alumni-restricted")]
|
|
public class AlumniRestrictedController : ControllerBase
|
|
{
|
|
private readonly ILogger<AlumniRestrictedController> _logger;
|
|
private IAlumnisService _dataServices;
|
|
|
|
public AlumniRestrictedController(ILogger<AlumniRestrictedController> logger, IAlumnisService dataServices)
|
|
{
|
|
_logger = logger;
|
|
_dataServices = dataServices;
|
|
}
|
|
|
|
[HttpGet]
|
|
[ProducesResponseType(typeof(IEnumerable<ResponseAlumniDto>), StatusCodes.Status200OK)]
|
|
[ProducesResponseType(StatusCodes.Status204NoContent)]
|
|
[RequireHttps]
|
|
public async Task<IActionResult> GetAlumniRestricted([FromQuery] string? lastname, [FromQuery] int page = 1, [FromQuery] int size = 5,
|
|
[FromQuery] AlumniOrderCriteria orderCriteria = AlumniOrderCriteria.None, [FromQuery] bool ascending = true)
|
|
{
|
|
var alumni = await _dataServices.GetAlumnisRestricted(lastname, page, size, orderCriteria, ascending);
|
|
if( alumni.Count == 0) return NoContent();
|
|
return Ok(alumni.Alumnis);
|
|
}
|
|
|
|
|
|
[HttpGet("{id}")]
|
|
[ProducesResponseType(typeof(ResponseAlumniDto), StatusCodes.Status200OK)]
|
|
[ProducesResponseType(StatusCodes.Status404NotFound)]
|
|
[RequireHttps]
|
|
public IActionResult GetAlumniRestrictedById(string id)
|
|
{
|
|
var alumni = _dataServices.GetAlumniRestrictedById(id);
|
|
return alumni.Result == null ? NotFound() : Ok(alumni.Result);
|
|
}
|
|
} |