feat: get lecture halls by campus
All checks were successful
.NET Test Pipeline / build-and-test (pull_request) Successful in 2m4s
All checks were successful
.NET Test Pipeline / build-and-test (pull_request) Successful in 2m4s
This commit is contained in:
parent
5536162521
commit
d02fb8becb
@ -3,7 +3,6 @@ using Microsoft.AspNetCore.Http;
|
|||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using Mirea.Api.DataAccess.Application.Cqrs.LectureHall.Queries.GetLectureHallDetails;
|
using Mirea.Api.DataAccess.Application.Cqrs.LectureHall.Queries.GetLectureHallDetails;
|
||||||
using Mirea.Api.DataAccess.Application.Cqrs.LectureHall.Queries.GetLectureHallList;
|
using Mirea.Api.DataAccess.Application.Cqrs.LectureHall.Queries.GetLectureHallList;
|
||||||
using Mirea.Api.DataAccess.Persistence;
|
|
||||||
using Mirea.Api.Dto.Responses;
|
using Mirea.Api.Dto.Responses;
|
||||||
using Mirea.Api.Endpoint.Common.Attributes;
|
using Mirea.Api.Endpoint.Common.Attributes;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
@ -12,7 +11,7 @@ using System.Threading.Tasks;
|
|||||||
|
|
||||||
namespace Mirea.Api.Endpoint.Controllers.V1
|
namespace Mirea.Api.Endpoint.Controllers.V1
|
||||||
{
|
{
|
||||||
public class LectureHallController(IMediator mediator, UberDbContext dbContext) : BaseControllerV1
|
public class LectureHallController(IMediator mediator) : BaseControllerV1
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Retrieves a list of all lecture halls.
|
/// Retrieves a list of all lecture halls.
|
||||||
@ -59,5 +58,27 @@ namespace Mirea.Api.Endpoint.Controllers.V1
|
|||||||
CampusName = result.CampusName
|
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
|
||||||
|
}));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user