From d02fb8becbb964e942b289ab712c0561c0e2c776 Mon Sep 17 00:00:00 2001 From: Polianin Nikita Date: Mon, 19 Feb 2024 12:03:10 +0300 Subject: [PATCH] feat: get lecture halls by campus --- .../Controllers/V1/LectureHallController.cs | 25 +++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/Endpoint/Controllers/V1/LectureHallController.cs b/Endpoint/Controllers/V1/LectureHallController.cs index 4ccede5..de2f21f 100644 --- a/Endpoint/Controllers/V1/LectureHallController.cs +++ b/Endpoint/Controllers/V1/LectureHallController.cs @@ -3,7 +3,6 @@ using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Mvc; using Mirea.Api.DataAccess.Application.Cqrs.LectureHall.Queries.GetLectureHallDetails; using Mirea.Api.DataAccess.Application.Cqrs.LectureHall.Queries.GetLectureHallList; -using Mirea.Api.DataAccess.Persistence; using Mirea.Api.Dto.Responses; using Mirea.Api.Endpoint.Common.Attributes; using System.Collections.Generic; @@ -12,7 +11,7 @@ using System.Threading.Tasks; namespace Mirea.Api.Endpoint.Controllers.V1 { - public class LectureHallController(IMediator mediator, UberDbContext dbContext) : BaseControllerV1 + public class LectureHallController(IMediator mediator) : BaseControllerV1 { /// /// Retrieves a list of all lecture halls. @@ -59,5 +58,27 @@ namespace Mirea.Api.Endpoint.Controllers.V1 CampusName = result.CampusName }); } + + /// + /// Retrieves a list of lecture halls by campus ID. + /// + /// The ID of the campus. + /// A list of lecture halls in the specified campus. + [HttpGet("{id:int}")] + [ProducesResponseType(StatusCodes.Status200OK)] + [BadRequestResponse] + [NotFoundResponse] + public async Task>> 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 + })); + } } }