Add controllers for the Get method #9

Merged
Wesser merged 33 commits from feat/controller-get into release/v1.0.0 2024-02-19 12:06:31 +03:00
Showing only changes of commit dfc9caf921 - Show all commits

View File

@ -0,0 +1,45 @@
using MediatR;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Mirea.Api.DataAccess.Application.Cqrs.Campus.Queries.GetCampusBasicInfoList;
using Mirea.Api.DataAccess.Application.Cqrs.Campus.Queries.GetCampusDetails;
using Mirea.Api.Endpoint.Common.Extensions;
using System.Threading.Tasks;
namespace Mirea.Api.Endpoint.Controllers.V1
{
public class CampusController(IMediator mediator) : BaseControllerV1
{
/// <summary>
/// Gets basic information about campuses.
/// </summary>
/// <returns>Basic information about campuses.</returns>
[HttpGet]
[ProducesResponseType(StatusCodes.Status200OK)]
public async Task<ActionResult<CampusBasicInfoVm>> GetBasicInfo()
{
var result = await mediator.Send(new GetCampusBasicInfoListQuery());
return Ok(result);
}
/// <summary>
/// Gets details of a specific campus by ID.
/// </summary>
/// <param name="id">Campus ID.</param>
/// <returns>Details of the specified campus.</returns>
[HttpGet("{id:int}")]
[ProducesResponseType(StatusCodes.Status200OK)]
[BadRequestResponse]
[NotFoundResponse]
public async Task<ActionResult<CampusDetailsVm>> GetDetails(int id)
{
var result = await mediator.Send(new GetCampusDetailsQuery()
{
Id = id
});
return Ok(result);
}
}
}