feat: add lesson type controller

This commit is contained in:
2025-02-01 17:08:00 +03:00
parent 5bcb7bfbc1
commit 03b6560bc4
7 changed files with 136 additions and 1 deletions

View 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
})
);
}
}