refactor: change the api path
All checks were successful
.NET Test Pipeline / build-and-test (pull_request) Successful in 1m59s
All checks were successful
.NET Test Pipeline / build-and-test (pull_request) Successful in 1m59s
This commit is contained in:
@ -9,76 +9,76 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Mirea.Api.Endpoint.Controllers.V1
|
||||
namespace Mirea.Api.Endpoint.Controllers.V1;
|
||||
|
||||
[ApiVersion("1.0")]
|
||||
public class LectureHallController(IMediator mediator) : BaseController
|
||||
{
|
||||
public class LectureHallController(IMediator mediator) : BaseControllerV1
|
||||
/// <summary>
|
||||
/// Retrieves a list of all lecture halls.
|
||||
/// </summary>
|
||||
/// <returns>A list of lecture halls.</returns>
|
||||
[HttpGet]
|
||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
public async Task<ActionResult<List<LectureHallResponse>>> Get()
|
||||
{
|
||||
/// <summary>
|
||||
/// Retrieves a list of all lecture halls.
|
||||
/// </summary>
|
||||
/// <returns>A list of lecture halls.</returns>
|
||||
[HttpGet]
|
||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
public async Task<ActionResult<List<LectureHallResponse>>> Get()
|
||||
{
|
||||
var result = await mediator.Send(new GetLectureHallListQuery());
|
||||
var result = await mediator.Send(new GetLectureHallListQuery());
|
||||
|
||||
return Ok(result.LectureHalls
|
||||
.Select(l => new LectureHallResponse()
|
||||
{
|
||||
Id = l.Id,
|
||||
Name = l.Name,
|
||||
CampusId = l.CampusId
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Retrieves details of a specific lecture hall by its ID.
|
||||
/// </summary>
|
||||
/// <param name="id">The ID of the lecture hall to retrieve.</param>
|
||||
/// <returns>The details of the specified lecture hall.</returns>
|
||||
[HttpGet("{id:int}")]
|
||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
[BadRequestResponse]
|
||||
[NotFoundResponse]
|
||||
public async Task<ActionResult<LectureHallDetailsResponse>> GetDetails(int id)
|
||||
{
|
||||
var result = await mediator.Send(new GetLectureHallInfoQuery()
|
||||
return Ok(result.LectureHalls
|
||||
.Select(l => new LectureHallResponse()
|
||||
{
|
||||
Id = id
|
||||
});
|
||||
|
||||
return Ok(new LectureHallDetailsResponse()
|
||||
{
|
||||
Id = result.Id,
|
||||
Name = result.Name,
|
||||
CampusId = result.CampusId,
|
||||
CampusCode = result.CampusCode,
|
||||
CampusName = result.CampusName
|
||||
});
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Retrieves a list of lecture halls by campus ID.
|
||||
/// </summary>
|
||||
/// <param name="id">The ID of the campus.</param>
|
||||
/// <returns>A list of lecture halls in the specified campus.</returns>
|
||||
[HttpGet("{id:int}")]
|
||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
[BadRequestResponse]
|
||||
[NotFoundResponse]
|
||||
public async Task<ActionResult<List<LectureHallResponse>>> GetByCampus(int id)
|
||||
{
|
||||
var result = await mediator.Send(new GetLectureHallListQuery());
|
||||
|
||||
return Ok(result.LectureHalls.Where(l => l.CampusId == id)
|
||||
.Select(l => new LectureHallResponse()
|
||||
{
|
||||
Id = l.Id,
|
||||
Name = l.Name,
|
||||
CampusId = l.CampusId
|
||||
}));
|
||||
}
|
||||
Id = l.Id,
|
||||
Name = l.Name,
|
||||
CampusId = l.CampusId
|
||||
})
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Retrieves details of a specific lecture hall by its ID.
|
||||
/// </summary>
|
||||
/// <param name="id">The ID of the lecture hall to retrieve.</param>
|
||||
/// <returns>The details of the specified lecture hall.</returns>
|
||||
[HttpGet("{id:int}")]
|
||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
[BadRequestResponse]
|
||||
[NotFoundResponse]
|
||||
public async Task<ActionResult<LectureHallDetailsResponse>> GetDetails(int id)
|
||||
{
|
||||
var result = await mediator.Send(new GetLectureHallInfoQuery()
|
||||
{
|
||||
Id = id
|
||||
});
|
||||
|
||||
return Ok(new LectureHallDetailsResponse()
|
||||
{
|
||||
Id = result.Id,
|
||||
Name = result.Name,
|
||||
CampusId = result.CampusId,
|
||||
CampusCode = result.CampusCode,
|
||||
CampusName = result.CampusName
|
||||
});
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Retrieves a list of lecture halls by campus ID.
|
||||
/// </summary>
|
||||
/// <param name="id">The ID of the campus.</param>
|
||||
/// <returns>A list of lecture halls in the specified campus.</returns>
|
||||
[HttpGet("GetByCampus/{id:int}")]
|
||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
[BadRequestResponse]
|
||||
[NotFoundResponse]
|
||||
public async Task<ActionResult<List<LectureHallResponse>>> GetByCampus(int id)
|
||||
{
|
||||
var result = await mediator.Send(new GetLectureHallListQuery());
|
||||
|
||||
return Ok(result.LectureHalls.Where(l => l.CampusId == id)
|
||||
.Select(l => new LectureHallResponse()
|
||||
{
|
||||
Id = l.Id,
|
||||
Name = l.Name,
|
||||
CampusId = l.CampusId
|
||||
}));
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user