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()
|
})
|
||||||
{
|
);
|
||||||
Id = result.Id,
|
|
||||||
CodeName = result.CodeName,
|
|
||||||
FullName = result.FullName,
|
|
||||||
Address = result.Address
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
/// <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
|
||||||
|
});
|
||||||
|
|
||||||
|
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
|
||||||
Page = page,
|
});
|
||||||
PageSize = pageSize
|
|
||||||
});
|
|
||||||
|
|
||||||
return Ok(result.Disciplines
|
return Ok(result.Disciplines
|
||||||
.Select(d => new DisciplineResponse()
|
.Select(d => new DisciplineResponse()
|
||||||
{
|
|
||||||
Id = d.Id,
|
|
||||||
Name = d.Name
|
|
||||||
})
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets details of a specific discipline by ID.
|
|
||||||
/// </summary>
|
|
||||||
/// <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 = d.Id,
|
||||||
});
|
Name = d.Name
|
||||||
|
})
|
||||||
return Ok(new DisciplineResponse()
|
);
|
||||||
{
|
|
||||||
Id = result.Id,
|
|
||||||
Name = result.Name
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets details of a specific discipline by ID.
|
||||||
|
/// </summary>
|
||||||
|
/// <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
|
||||||
|
});
|
||||||
|
|
||||||
|
return Ok(new DisciplineResponse()
|
||||||
|
{
|
||||||
|
Id = result.Id,
|
||||||
|
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
|
||||||
Page = page,
|
});
|
||||||
PageSize = pageSize
|
|
||||||
});
|
|
||||||
|
|
||||||
return Ok(result.Faculties
|
return Ok(result.Faculties
|
||||||
.Select(f => new FacultyResponse()
|
.Select(f => new FacultyResponse()
|
||||||
{
|
|
||||||
Id = f.Id,
|
|
||||||
Name = f.Name,
|
|
||||||
CampusId = f.CampusId
|
|
||||||
})
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets details of a specific faculty by ID.
|
|
||||||
/// </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 = f.Id,
|
||||||
});
|
Name = f.Name,
|
||||||
|
CampusId = f.CampusId
|
||||||
return Ok(new FacultyDetailsResponse()
|
})
|
||||||
{
|
);
|
||||||
Id = result.Id,
|
|
||||||
Name = result.Name,
|
|
||||||
CampusId = result.CampusId,
|
|
||||||
CampusCode = result.CampusCode,
|
|
||||||
CampusName = result.CampusName
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets details of a specific faculty by ID.
|
||||||
|
/// </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
|
||||||
|
});
|
||||||
|
|
||||||
|
return Ok(new FacultyDetailsResponse()
|
||||||
|
{
|
||||||
|
Id = result.Id,
|
||||||
|
Name = result.Name,
|
||||||
|
CampusId = result.CampusId,
|
||||||
|
CampusCode = result.CampusCode,
|
||||||
|
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)
|
||||||
var current = DateTime.Now;
|
&& !int.TryParse(groupName.Split('-')[^1][..2], out yearOfGroup))
|
||||||
if (!int.TryParse(groupName[2..], out var yearOfGroup)
|
return -1;
|
||||||
&& !int.TryParse(groupName.Split('-')[^1][..2], out yearOfGroup))
|
|
||||||
return -1;
|
|
||||||
|
|
||||||
// Convert a two-digit year to a four-digit one
|
// Convert a two-digit year to a four-digit one
|
||||||
yearOfGroup += current.Year / 100 * 100;
|
yearOfGroup += current.Year / 100 * 100;
|
||||||
|
|
||||||
return current.Year - yearOfGroup + (current.Month < 9 ? 0 : 1);
|
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,
|
|
||||||
PageSize = pageSize
|
|
||||||
});
|
|
||||||
|
|
||||||
return Ok(result.Groups
|
|
||||||
.Select(g => new GroupResponse()
|
|
||||||
{
|
|
||||||
Id = g.Id,
|
|
||||||
Name = g.Name,
|
|
||||||
FacultyId = g.FacultyId,
|
|
||||||
CourseNumber = GetCourseNumber(g.Name)
|
|
||||||
})
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 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
|
|
||||||
});
|
|
||||||
|
|
||||||
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());
|
|
||||||
|
|
||||||
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
|
|
||||||
}));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
/// <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,
|
||||||
|
PageSize = pageSize
|
||||||
|
});
|
||||||
|
|
||||||
|
return Ok(result.Groups
|
||||||
|
.Select(g => new GroupResponse()
|
||||||
|
{
|
||||||
|
Id = g.Id,
|
||||||
|
Name = g.Name,
|
||||||
|
FacultyId = g.FacultyId,
|
||||||
|
CourseNumber = GetCourseNumber(g.Name)
|
||||||
|
})
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 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
|
||||||
|
});
|
||||||
|
|
||||||
|
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("GetByFaculty/{id:int}")]
|
||||||
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||||
|
[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()
|
})
|
||||||
{
|
);
|
||||||
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
|
|
||||||
}));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
/// <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
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
}
|
@ -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