Add Application configuration #11
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
namespace Mirea.Api.Endpoint.Controllers;
|
namespace Mirea.Api.Endpoint.Controllers;
|
||||||
|
|
||||||
|
[Produces("application/json")]
|
||||||
|
[Route("api/v{version:apiVersion}/[controller]")]
|
||||||
[ApiController]
|
[ApiController]
|
||||||
[Route("api/[controller]/[action]")]
|
|
||||||
public class BaseController : ControllerBase;
|
public class BaseController : ControllerBase;
|
@ -1,8 +0,0 @@
|
|||||||
using Microsoft.AspNetCore.Mvc;
|
|
||||||
|
|
||||||
namespace Mirea.Api.Endpoint.Controllers.V1;
|
|
||||||
|
|
||||||
[ApiVersion("1.0")]
|
|
||||||
[Produces("application/json")]
|
|
||||||
[Route("api/v{version:apiVersion}/[controller]/[action]")]
|
|
||||||
public class BaseControllerV1 : BaseController;
|
|
@ -9,53 +9,53 @@ using System.Collections.Generic;
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace Mirea.Api.Endpoint.Controllers.V1
|
namespace Mirea.Api.Endpoint.Controllers.V1;
|
||||||
|
|
||||||
|
[ApiVersion("1.0")]
|
||||||
|
public class CampusController(IMediator mediator) : BaseController
|
||||||
{
|
{
|
||||||
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<List<CampusBasicInfoResponse>>> Get()
|
||||||
{
|
{
|
||||||
/// <summary>
|
var result = await mediator.Send(new GetCampusBasicInfoListQuery());
|
||||||
/// Gets basic information about campuses.
|
|
||||||
/// </summary>
|
|
||||||
/// <returns>Basic information about campuses.</returns>
|
|
||||||
[HttpGet]
|
|
||||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
|
||||||
public async Task<ActionResult<List<CampusBasicInfoResponse>>> Get()
|
|
||||||
{
|
|
||||||
var result = await mediator.Send(new GetCampusBasicInfoListQuery());
|
|
||||||
|
|
||||||
return Ok(result.Campuses
|
return Ok(result.Campuses
|
||||||
.Select(c => new CampusBasicInfoResponse()
|
.Select(c => new CampusBasicInfoResponse()
|
||||||
{
|
|
||||||
Id = c.Id,
|
|
||||||
CodeName = c.CodeName,
|
|
||||||
FullName = c.FullName
|
|
||||||
})
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <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<CampusDetailsResponse>> GetDetails(int id)
|
|
||||||
{
|
|
||||||
var result = await mediator.Send(new GetCampusDetailsQuery()
|
|
||||||
{
|
{
|
||||||
Id = id
|
Id = c.Id,
|
||||||
});
|
CodeName = c.CodeName,
|
||||||
|
FullName = c.FullName
|
||||||
|
})
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
return Ok(new CampusDetailsResponse()
|
/// <summary>
|
||||||
{
|
/// Gets details of a specific campus by ID.
|
||||||
Id = result.Id,
|
/// </summary>
|
||||||
CodeName = result.CodeName,
|
/// <param name="id">Campus ID.</param>
|
||||||
FullName = result.FullName,
|
/// <returns>Details of the specified campus.</returns>
|
||||||
Address = result.Address
|
[HttpGet("{id:int}")]
|
||||||
});
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||||
}
|
[BadRequestResponse]
|
||||||
|
[NotFoundResponse]
|
||||||
|
public async Task<ActionResult<CampusDetailsResponse>> GetDetails(int id)
|
||||||
|
{
|
||||||
|
var result = await mediator.Send(new GetCampusDetailsQuery()
|
||||||
|
{
|
||||||
|
Id = id
|
||||||
|
});
|
||||||
|
|
||||||
|
return Ok(new CampusDetailsResponse()
|
||||||
|
{
|
||||||
|
Id = result.Id,
|
||||||
|
CodeName = result.CodeName,
|
||||||
|
FullName = result.FullName,
|
||||||
|
Address = result.Address
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -9,57 +9,57 @@ using System.Collections.Generic;
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace Mirea.Api.Endpoint.Controllers.V1
|
namespace Mirea.Api.Endpoint.Controllers.V1;
|
||||||
|
|
||||||
|
[ApiVersion("1.0")]
|
||||||
|
public class DisciplineController(IMediator mediator) : BaseController
|
||||||
{
|
{
|
||||||
public class DisciplineController(IMediator mediator) : BaseControllerV1
|
/// <summary>
|
||||||
|
/// Gets a paginated list of disciplines.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="page">Page number. Start from 0.</param>
|
||||||
|
/// <param name="pageSize">Number of items per page.</param>
|
||||||
|
/// <returns>Paginated list of disciplines.</returns>
|
||||||
|
[HttpGet]
|
||||||
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||||
|
[BadRequestResponse]
|
||||||
|
public async Task<ActionResult<List<DisciplineResponse>>> Get([FromQuery] int? page, [FromQuery] int? pageSize)
|
||||||
{
|
{
|
||||||
/// <summary>
|
var result = await mediator.Send(new GetDisciplineListQuery()
|
||||||
/// Gets a paginated list of disciplines.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="page">Page number. Start from 0.</param>
|
|
||||||
/// <param name="pageSize">Number of items per page.</param>
|
|
||||||
/// <returns>Paginated list of disciplines.</returns>
|
|
||||||
[HttpGet]
|
|
||||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
|
||||||
[BadRequestResponse]
|
|
||||||
public async Task<ActionResult<List<DisciplineResponse>>> Get([FromQuery] int? page, [FromQuery] int? pageSize)
|
|
||||||
{
|
{
|
||||||
var result = await mediator.Send(new GetDisciplineListQuery()
|
Page = page,
|
||||||
|
PageSize = pageSize
|
||||||
|
});
|
||||||
|
|
||||||
|
return Ok(result.Disciplines
|
||||||
|
.Select(d => new DisciplineResponse()
|
||||||
{
|
{
|
||||||
Page = page,
|
Id = d.Id,
|
||||||
PageSize = pageSize
|
Name = d.Name
|
||||||
});
|
})
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
return Ok(result.Disciplines
|
/// <summary>
|
||||||
.Select(d => new DisciplineResponse()
|
/// Gets details of a specific discipline by ID.
|
||||||
{
|
/// </summary>
|
||||||
Id = d.Id,
|
/// <param name="id">Discipline ID.</param>
|
||||||
Name = d.Name
|
/// <returns>Details of the specified discipline.</returns>
|
||||||
})
|
[HttpGet("{id:int}")]
|
||||||
);
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||||
}
|
[BadRequestResponse]
|
||||||
|
[NotFoundResponse]
|
||||||
/// <summary>
|
public async Task<ActionResult<DisciplineResponse>> GetDetails(int id)
|
||||||
/// Gets details of a specific discipline by ID.
|
{
|
||||||
/// </summary>
|
var result = await mediator.Send(new GetDisciplineInfoQuery()
|
||||||
/// <param name="id">Discipline ID.</param>
|
|
||||||
/// <returns>Details of the specified discipline.</returns>
|
|
||||||
[HttpGet("{id:int}")]
|
|
||||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
|
||||||
[BadRequestResponse]
|
|
||||||
[NotFoundResponse]
|
|
||||||
public async Task<ActionResult<DisciplineResponse>> GetDetails(int id)
|
|
||||||
{
|
{
|
||||||
var result = await mediator.Send(new GetDisciplineInfoQuery()
|
Id = id
|
||||||
{
|
});
|
||||||
Id = id
|
|
||||||
});
|
|
||||||
|
|
||||||
return Ok(new DisciplineResponse()
|
return Ok(new DisciplineResponse()
|
||||||
{
|
{
|
||||||
Id = result.Id,
|
Id = result.Id,
|
||||||
Name = result.Name
|
Name = result.Name
|
||||||
});
|
});
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -9,61 +9,61 @@ using System.Collections.Generic;
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace Mirea.Api.Endpoint.Controllers.V1
|
namespace Mirea.Api.Endpoint.Controllers.V1;
|
||||||
|
|
||||||
|
[ApiVersion("1.0")]
|
||||||
|
public class FacultyController(IMediator mediator) : BaseController
|
||||||
{
|
{
|
||||||
public class FacultyController(IMediator mediator) : BaseControllerV1
|
/// <summary>
|
||||||
|
/// Gets a paginated list of faculties.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="page">Page number. Start from 0.</param>
|
||||||
|
/// <param name="pageSize">Number of items per page.</param>
|
||||||
|
/// <returns>Paginated list of faculties.</returns>
|
||||||
|
[HttpGet]
|
||||||
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||||
|
[BadRequestResponse]
|
||||||
|
public async Task<ActionResult<List<FacultyResponse>>> Get([FromQuery] int? page, [FromQuery] int? pageSize)
|
||||||
{
|
{
|
||||||
/// <summary>
|
var result = await mediator.Send(new GetFacultyListQuery()
|
||||||
/// Gets a paginated list of faculties.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="page">Page number. Start from 0.</param>
|
|
||||||
/// <param name="pageSize">Number of items per page.</param>
|
|
||||||
/// <returns>Paginated list of faculties.</returns>
|
|
||||||
[HttpGet]
|
|
||||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
|
||||||
[BadRequestResponse]
|
|
||||||
public async Task<ActionResult<List<FacultyResponse>>> Get([FromQuery] int? page, [FromQuery] int? pageSize)
|
|
||||||
{
|
{
|
||||||
var result = await mediator.Send(new GetFacultyListQuery()
|
Page = page,
|
||||||
|
PageSize = pageSize
|
||||||
|
});
|
||||||
|
|
||||||
|
return Ok(result.Faculties
|
||||||
|
.Select(f => new FacultyResponse()
|
||||||
{
|
{
|
||||||
Page = page,
|
Id = f.Id,
|
||||||
PageSize = pageSize
|
Name = f.Name,
|
||||||
});
|
CampusId = f.CampusId
|
||||||
|
})
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
return Ok(result.Faculties
|
/// <summary>
|
||||||
.Select(f => new FacultyResponse()
|
/// Gets details of a specific faculty by ID.
|
||||||
{
|
/// </summary>
|
||||||
Id = f.Id,
|
/// <param name="id">Faculty ID.</param>
|
||||||
Name = f.Name,
|
/// <returns>Details of the specified faculty.</returns>
|
||||||
CampusId = f.CampusId
|
[HttpGet("{id:int}")]
|
||||||
})
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||||
);
|
[BadRequestResponse]
|
||||||
}
|
[NotFoundResponse]
|
||||||
|
public async Task<ActionResult<FacultyDetailsResponse>> GetDetails(int id)
|
||||||
/// <summary>
|
{
|
||||||
/// Gets details of a specific faculty by ID.
|
var result = await mediator.Send(new GetFacultyInfoQuery()
|
||||||
/// </summary>
|
|
||||||
/// <param name="id">Faculty ID.</param>
|
|
||||||
/// <returns>Details of the specified faculty.</returns>
|
|
||||||
[HttpGet("{id:int}")]
|
|
||||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
|
||||||
[BadRequestResponse]
|
|
||||||
[NotFoundResponse]
|
|
||||||
public async Task<ActionResult<FacultyDetailsResponse>> GetDetails(int id)
|
|
||||||
{
|
{
|
||||||
var result = await mediator.Send(new GetFacultyInfoQuery()
|
Id = id
|
||||||
{
|
});
|
||||||
Id = id
|
|
||||||
});
|
|
||||||
|
|
||||||
return Ok(new FacultyDetailsResponse()
|
return Ok(new FacultyDetailsResponse()
|
||||||
{
|
{
|
||||||
Id = result.Id,
|
Id = result.Id,
|
||||||
Name = result.Name,
|
Name = result.Name,
|
||||||
CampusId = result.CampusId,
|
CampusId = result.CampusId,
|
||||||
CampusCode = result.CampusCode,
|
CampusCode = result.CampusCode,
|
||||||
CampusName = result.CampusName
|
CampusName = result.CampusName
|
||||||
});
|
});
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -10,99 +10,99 @@ using System.Collections.Generic;
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace Mirea.Api.Endpoint.Controllers.V1
|
namespace Mirea.Api.Endpoint.Controllers.V1;
|
||||||
|
|
||||||
|
[ApiVersion("1.0")]
|
||||||
|
public class GroupController(IMediator mediator) : BaseController
|
||||||
{
|
{
|
||||||
public class GroupController(IMediator mediator) : BaseControllerV1
|
private static int GetCourseNumber(string groupName)
|
||||||
{
|
{
|
||||||
private static int GetCourseNumber(string groupName)
|
var current = DateTime.Now;
|
||||||
|
if (!int.TryParse(groupName[2..], out var yearOfGroup)
|
||||||
|
&& !int.TryParse(groupName.Split('-')[^1][..2], out yearOfGroup))
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
// Convert a two-digit year to a four-digit one
|
||||||
|
yearOfGroup += current.Year / 100 * 100;
|
||||||
|
|
||||||
|
return current.Year - yearOfGroup + (current.Month < 9 ? 0 : 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Retrieves a list of groups.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="page">The page number for pagination (optional).</param>
|
||||||
|
/// <param name="pageSize">The page size for pagination (optional).</param>
|
||||||
|
/// <returns>A list of groups.</returns>
|
||||||
|
[HttpGet]
|
||||||
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||||
|
[BadRequestResponse]
|
||||||
|
public async Task<ActionResult<List<GroupResponse>>> Get([FromQuery] int? page, [FromQuery] int? pageSize)
|
||||||
|
{
|
||||||
|
var result = await mediator.Send(new GetGroupListQuery()
|
||||||
{
|
{
|
||||||
var current = DateTime.Now;
|
Page = page,
|
||||||
if (!int.TryParse(groupName[2..], out var yearOfGroup)
|
PageSize = pageSize
|
||||||
&& !int.TryParse(groupName.Split('-')[^1][..2], out yearOfGroup))
|
});
|
||||||
return -1;
|
|
||||||
|
|
||||||
// Convert a two-digit year to a four-digit one
|
return Ok(result.Groups
|
||||||
yearOfGroup += current.Year / 100 * 100;
|
.Select(g => new GroupResponse()
|
||||||
|
|
||||||
return current.Year - yearOfGroup + (current.Month < 9 ? 0 : 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Retrieves a list of groups.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="page">The page number for pagination (optional).</param>
|
|
||||||
/// <param name="pageSize">The page size for pagination (optional).</param>
|
|
||||||
/// <returns>A list of groups.</returns>
|
|
||||||
[HttpGet]
|
|
||||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
|
||||||
[BadRequestResponse]
|
|
||||||
public async Task<ActionResult<List<GroupResponse>>> Get([FromQuery] int? page, [FromQuery] int? pageSize)
|
|
||||||
{
|
|
||||||
var result = await mediator.Send(new GetGroupListQuery()
|
|
||||||
{
|
{
|
||||||
Page = page,
|
Id = g.Id,
|
||||||
PageSize = pageSize
|
Name = g.Name,
|
||||||
});
|
FacultyId = g.FacultyId,
|
||||||
|
CourseNumber = GetCourseNumber(g.Name)
|
||||||
|
})
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
return Ok(result.Groups
|
/// <summary>
|
||||||
.Select(g => new GroupResponse()
|
/// Retrieves detailed information about a specific group.
|
||||||
{
|
/// </summary>
|
||||||
Id = g.Id,
|
/// <param name="id">The ID of the group to retrieve.</param>
|
||||||
Name = g.Name,
|
/// <returns>Detailed information about the group.</returns>
|
||||||
FacultyId = g.FacultyId,
|
[HttpGet("{id:int}")]
|
||||||
CourseNumber = GetCourseNumber(g.Name)
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||||
})
|
[BadRequestResponse]
|
||||||
);
|
[NotFoundResponse]
|
||||||
}
|
public async Task<ActionResult<GroupDetailsResponse>> GetDetails(int id)
|
||||||
|
{
|
||||||
/// <summary>
|
var result = await mediator.Send(new GetGroupInfoQuery()
|
||||||
/// Retrieves detailed information about a specific group.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="id">The ID of the group to retrieve.</param>
|
|
||||||
/// <returns>Detailed information about the group.</returns>
|
|
||||||
[HttpGet("{id:int}")]
|
|
||||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
|
||||||
[BadRequestResponse]
|
|
||||||
[NotFoundResponse]
|
|
||||||
public async Task<ActionResult<GroupDetailsResponse>> GetDetails(int id)
|
|
||||||
{
|
{
|
||||||
var result = await mediator.Send(new GetGroupInfoQuery()
|
Id = id
|
||||||
{
|
});
|
||||||
Id = id
|
|
||||||
});
|
|
||||||
|
|
||||||
return Ok(new GroupDetailsResponse()
|
return Ok(new GroupDetailsResponse()
|
||||||
{
|
|
||||||
Id = result.Id,
|
|
||||||
Name = result.Name,
|
|
||||||
FacultyId = result.FacultyId,
|
|
||||||
FacultyName = result.Faculty,
|
|
||||||
CourseNumber = GetCourseNumber(result.Name)
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Retrieves a list of groups by faculty ID.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="id">The ID of the faculty.</param>
|
|
||||||
/// <returns>A list of groups belonging to the specified faculty.</returns>
|
|
||||||
[HttpGet("{id:int}")]
|
|
||||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
|
||||||
[BadRequestResponse]
|
|
||||||
[NotFoundResponse]
|
|
||||||
public async Task<ActionResult<List<GroupResponse>>> GetByFaculty(int id)
|
|
||||||
{
|
{
|
||||||
var result = await mediator.Send(new GetGroupListQuery());
|
Id = result.Id,
|
||||||
|
Name = result.Name,
|
||||||
|
FacultyId = result.FacultyId,
|
||||||
|
FacultyName = result.Faculty,
|
||||||
|
CourseNumber = GetCourseNumber(result.Name)
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
return Ok(result.Groups
|
/// <summary>
|
||||||
.Where(g => g.FacultyId == id)
|
/// Retrieves a list of groups by faculty ID.
|
||||||
.Select(g => new GroupResponse()
|
/// </summary>
|
||||||
{
|
/// <param name="id">The ID of the faculty.</param>
|
||||||
Id = g.Id,
|
/// <returns>A list of groups belonging to the specified faculty.</returns>
|
||||||
Name = g.Name,
|
[HttpGet("GetByFaculty/{id:int}")]
|
||||||
CourseNumber = GetCourseNumber(g.Name),
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||||
FacultyId = g.FacultyId
|
[BadRequestResponse]
|
||||||
}));
|
[NotFoundResponse]
|
||||||
}
|
public async Task<ActionResult<List<GroupResponse>>> 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
|
||||||
|
}));
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -9,76 +9,76 @@ using System.Collections.Generic;
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Threading.Tasks;
|
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>
|
var result = await mediator.Send(new GetLectureHallListQuery());
|
||||||
/// 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());
|
|
||||||
|
|
||||||
return Ok(result.LectureHalls
|
return Ok(result.LectureHalls
|
||||||
.Select(l => new LectureHallResponse()
|
.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()
|
|
||||||
{
|
{
|
||||||
Id = id
|
Id = l.Id,
|
||||||
});
|
Name = l.Name,
|
||||||
|
CampusId = l.CampusId
|
||||||
|
})
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
return Ok(new LectureHallDetailsResponse()
|
/// <summary>
|
||||||
{
|
/// Retrieves details of a specific lecture hall by its ID.
|
||||||
Id = result.Id,
|
/// </summary>
|
||||||
Name = result.Name,
|
/// <param name="id">The ID of the lecture hall to retrieve.</param>
|
||||||
CampusId = result.CampusId,
|
/// <returns>The details of the specified lecture hall.</returns>
|
||||||
CampusCode = result.CampusCode,
|
[HttpGet("{id:int}")]
|
||||||
CampusName = result.CampusName
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||||
});
|
[BadRequestResponse]
|
||||||
}
|
[NotFoundResponse]
|
||||||
|
public async Task<ActionResult<LectureHallDetailsResponse>> GetDetails(int id)
|
||||||
/// <summary>
|
{
|
||||||
/// Retrieves a list of lecture halls by campus ID.
|
var result = await mediator.Send(new GetLectureHallInfoQuery()
|
||||||
/// </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());
|
Id = id
|
||||||
|
});
|
||||||
|
|
||||||
return Ok(result.LectureHalls.Where(l => l.CampusId == id)
|
return Ok(new LectureHallDetailsResponse()
|
||||||
.Select(l => new LectureHallResponse()
|
{
|
||||||
{
|
Id = result.Id,
|
||||||
Id = l.Id,
|
Name = result.Name,
|
||||||
Name = l.Name,
|
CampusId = result.CampusId,
|
||||||
CampusId = l.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
|
||||||
|
}));
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -11,7 +11,8 @@ using System.Threading.Tasks;
|
|||||||
|
|
||||||
namespace Mirea.Api.Endpoint.Controllers.V1;
|
namespace Mirea.Api.Endpoint.Controllers.V1;
|
||||||
|
|
||||||
public class ProfessorController(IMediator mediator) : BaseControllerV1
|
[ApiVersion("1.0")]
|
||||||
|
public class ProfessorController(IMediator mediator) : BaseController
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Retrieves a list of professors.
|
/// Retrieves a list of professors.
|
||||||
|
@ -12,7 +12,8 @@ using System.Threading.Tasks;
|
|||||||
|
|
||||||
namespace Mirea.Api.Endpoint.Controllers.V1;
|
namespace Mirea.Api.Endpoint.Controllers.V1;
|
||||||
|
|
||||||
public class ScheduleController(IMediator mediator) : BaseControllerV1
|
[ApiVersion("1.0")]
|
||||||
|
public class ScheduleController(IMediator mediator) : BaseController
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Retrieves schedules based on various filters.
|
/// Retrieves schedules based on various filters.
|
||||||
@ -25,7 +26,6 @@ public class ScheduleController(IMediator mediator) : BaseControllerV1
|
|||||||
[BadRequestResponse]
|
[BadRequestResponse]
|
||||||
[NotFoundResponse]
|
[NotFoundResponse]
|
||||||
public async Task<ActionResult<List<ScheduleResponse>>> Get([FromBody] ScheduleRequest request)
|
public async Task<ActionResult<List<ScheduleResponse>>> Get([FromBody] ScheduleRequest request)
|
||||||
|
|
||||||
{
|
{
|
||||||
if ((request.Groups == null || request.Groups.Length == 0) &&
|
if ((request.Groups == null || request.Groups.Length == 0) &&
|
||||||
(request.Disciplines == null || request.Disciplines.Length == 0) &&
|
(request.Disciplines == null || request.Disciplines.Length == 0) &&
|
||||||
@ -85,7 +85,7 @@ public class ScheduleController(IMediator mediator) : BaseControllerV1
|
|||||||
/// <param name="professors">An array of professor IDs.</param>
|
/// <param name="professors">An array of professor IDs.</param>
|
||||||
/// <param name="lectureHalls">An array of lecture hall IDs.</param>
|
/// <param name="lectureHalls">An array of lecture hall IDs.</param>
|
||||||
/// <returns>A response containing schedules for the specified group.</returns>
|
/// <returns>A response containing schedules for the specified group.</returns>
|
||||||
[HttpGet("{id:int}")]
|
[HttpGet("GetByGroup/{id:int}")]
|
||||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||||
[ProducesResponseType(StatusCodes.Status204NoContent)]
|
[ProducesResponseType(StatusCodes.Status204NoContent)]
|
||||||
[BadRequestResponse]
|
[BadRequestResponse]
|
||||||
@ -142,7 +142,7 @@ public class ScheduleController(IMediator mediator) : BaseControllerV1
|
|||||||
/// <param name="groups">An array of group IDs.</param>
|
/// <param name="groups">An array of group IDs.</param>
|
||||||
/// <param name="lectureHalls">An array of lecture hall IDs.</param>
|
/// <param name="lectureHalls">An array of lecture hall IDs.</param>
|
||||||
/// <returns>A response containing schedules for the specified professor.</returns>
|
/// <returns>A response containing schedules for the specified professor.</returns>
|
||||||
[HttpGet("{id:int}")]
|
[HttpGet("GetByProfessor/{id:int}")]
|
||||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||||
[ProducesResponseType(StatusCodes.Status204NoContent)]
|
[ProducesResponseType(StatusCodes.Status204NoContent)]
|
||||||
[BadRequestResponse]
|
[BadRequestResponse]
|
||||||
@ -203,7 +203,7 @@ public class ScheduleController(IMediator mediator) : BaseControllerV1
|
|||||||
/// <param name="professors">An array of professor IDs.</param>
|
/// <param name="professors">An array of professor IDs.</param>
|
||||||
/// <param name="groups">An array of group IDs.</param>
|
/// <param name="groups">An array of group IDs.</param>
|
||||||
/// <returns>A response containing schedules for the specified lecture hall.</returns>
|
/// <returns>A response containing schedules for the specified lecture hall.</returns>
|
||||||
[HttpGet("{id:int}")]
|
[HttpGet("GetByLectureHall/{id:int}")]
|
||||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||||
[ProducesResponseType(StatusCodes.Status204NoContent)]
|
[ProducesResponseType(StatusCodes.Status204NoContent)]
|
||||||
[BadRequestResponse]
|
[BadRequestResponse]
|
||||||
@ -264,7 +264,7 @@ public class ScheduleController(IMediator mediator) : BaseControllerV1
|
|||||||
/// <param name="professors">An array of professor IDs.</param>
|
/// <param name="professors">An array of professor IDs.</param>
|
||||||
/// <param name="lectureHalls">An array of lecture hall IDs.</param>
|
/// <param name="lectureHalls">An array of lecture hall IDs.</param>
|
||||||
/// <returns>A response containing schedules for the specified discipline.</returns>
|
/// <returns>A response containing schedules for the specified discipline.</returns>
|
||||||
[HttpGet("{id:int}")]
|
[HttpGet("GetByDiscipline/{id:int}")]
|
||||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||||
[ProducesResponseType(StatusCodes.Status204NoContent)]
|
[ProducesResponseType(StatusCodes.Status204NoContent)]
|
||||||
[BadRequestResponse]
|
[BadRequestResponse]
|
||||||
|
Loading…
Reference in New Issue
Block a user