feat: add lesson type controller
This commit is contained in:
43
Endpoint/Controllers/V1/LessonTypeController.cs
Normal file
43
Endpoint/Controllers/V1/LessonTypeController.cs
Normal file
@ -0,0 +1,43 @@
|
||||
using Asp.Versioning;
|
||||
using MediatR;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Mirea.Api.DataAccess.Application.Cqrs.TypeOfOccupation.Queries.GetTypeOfOccupationList;
|
||||
using Mirea.Api.Dto.Responses;
|
||||
using Mirea.Api.Endpoint.Common.Attributes;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Mirea.Api.Endpoint.Controllers.V1;
|
||||
|
||||
[ApiVersion("1.0")]
|
||||
[CacheMaxAge(true)]
|
||||
public class LessonTypeController(IMediator mediator) : BaseController
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets a paginated list of type of occupation.
|
||||
/// </summary>
|
||||
/// <param name="page">Page number. Start from 0.</param>
|
||||
/// <param name="pageSize">Number of items per page.</param>
|
||||
/// <returns>Paginated list of type of occupation.</returns>
|
||||
[HttpGet]
|
||||
[BadRequestResponse]
|
||||
public async Task<ActionResult<List<LessonTypeResponse>>> Get([FromQuery][Range(0, int.MaxValue)] int? page,
|
||||
[FromQuery][Range(1, int.MaxValue)] int? pageSize)
|
||||
{
|
||||
var result = await mediator.Send(new GetTypeOfOccupationListQuery()
|
||||
{
|
||||
Page = page,
|
||||
PageSize = pageSize
|
||||
});
|
||||
|
||||
return Ok(result.TypeOfOccupations
|
||||
.Select(f => new LessonTypeResponse()
|
||||
{
|
||||
Id = f.Id,
|
||||
Name = f.Name
|
||||
})
|
||||
);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user