From 5536162521b8831224505353892f026f99fb12d3 Mon Sep 17 00:00:00 2001 From: Polianin Nikita Date: Mon, 19 Feb 2024 12:02:37 +0300 Subject: [PATCH] feat: add get group by faculty id --- Endpoint/Controllers/V1/GroupController.cs | 24 ++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/Endpoint/Controllers/V1/GroupController.cs b/Endpoint/Controllers/V1/GroupController.cs index 3dc7966..cead029 100644 --- a/Endpoint/Controllers/V1/GroupController.cs +++ b/Endpoint/Controllers/V1/GroupController.cs @@ -80,5 +80,29 @@ namespace Mirea.Api.Endpoint.Controllers.V1 CourseNumber = GetCourseNumber(result.Name) }); } + + /// + /// Retrieves a list of groups by faculty ID. + /// + /// The ID of the faculty. + /// A list of groups belonging to the specified faculty. + [HttpGet("{id:int}")] + [ProducesResponseType(StatusCodes.Status200OK)] + [BadRequestResponse] + [NotFoundResponse] + public async Task>> GetByFaculty(int id) + { + var result = await mediator.Send(new GetGroupListQuery()); + + return Ok(result.Groups + .Where(g => g.FacultyId == id) + .Select(g => new GroupResponse() + { + Id = g.Id, + Name = g.Name, + CourseNumber = GetCourseNumber(g.Name), + FacultyId = g.FacultyId + })); + } } }