feat: add specific weeks
All checks were successful
.NET Test Pipeline / build-and-test (pull_request) Successful in 1m52s

This commit is contained in:
Polianin Nikita 2024-05-19 13:53:25 +03:00
parent 22579038d3
commit 0d3461b769
7 changed files with 125 additions and 13 deletions

View File

@ -39,6 +39,29 @@ public class GroupScheduleInfo
[Required] [Required]
public required int DisciplineId { get; set; } public required int DisciplineId { get; set; }
/// <summary>
/// Gets or sets exclude or include weeks for a specific discipline.
/// </summary>
/// <remarks>
/// If is <see langword="true"/>, then the values in <see cref="Weeks"/> show the weeks when there will be no discipline.
/// <br/>
/// If is <see langword="false"/>, then the values in <see cref="Weeks"/> indicate the weeks during which a particular discipline will be studied.
/// <br/>
/// If is <see langword="null"/>, then there are no specific <see cref="Weeks"/>
/// </remarks>
///
public bool? IsExcludedWeeks { get; set; }
/// <summary>
/// The week numbers required for the correct display of the schedule.
/// <br/>
/// Whether there will be <see cref="Discipline"/> during the week or not depends on the <see cref="IsExcludedWeeks"/> property.
/// </summary>
/// <remarks>
/// To get the current week's number, use other queries.
/// </remarks>
public IEnumerable<int>? Weeks { get; set; }
/// <summary> /// <summary>
/// Gets or sets the type of occupation for the schedule entry. /// Gets or sets the type of occupation for the schedule entry.
/// </summary> /// </summary>

View File

@ -39,6 +39,29 @@ public class LectureHallScheduleInfo
[Required] [Required]
public required int DisciplineId { get; set; } public required int DisciplineId { get; set; }
/// <summary>
/// Gets or sets exclude or include weeks for a specific discipline.
/// </summary>
/// <remarks>
/// If is <see langword="true"/>, then the values in <see cref="Weeks"/> show the weeks when there will be no discipline.
/// <br/>
/// If is <see langword="false"/>, then the values in <see cref="Weeks"/> indicate the weeks during which a particular discipline will be studied.
/// <br/>
/// If is <see langword="null"/>, then there are no specific <see cref="Weeks"/>
/// </remarks>
///
public bool? IsExcludedWeeks { get; set; }
/// <summary>
/// The week numbers required for the correct display of the schedule.
/// <br/>
/// Whether there will be <see cref="Discipline"/> during the week or not depends on the <see cref="IsExcludedWeeks"/> property.
/// </summary>
/// <remarks>
/// To get the current week's number, use other queries.
/// </remarks>
public IEnumerable<int>? Weeks { get; set; }
/// <summary> /// <summary>
/// Gets or sets the type of occupation for the schedule entry. /// Gets or sets the type of occupation for the schedule entry.
/// </summary> /// </summary>

View File

@ -39,6 +39,29 @@ public class ProfessorScheduleInfo
[Required] [Required]
public required int DisciplineId { get; set; } public required int DisciplineId { get; set; }
/// <summary>
/// Gets or sets exclude or include weeks for a specific discipline.
/// </summary>
/// <remarks>
/// If is <see langword="true"/>, then the values in <see cref="Weeks"/> show the weeks when there will be no discipline.
/// <br/>
/// If is <see langword="false"/>, then the values in <see cref="Weeks"/> indicate the weeks during which a particular discipline will be studied.
/// <br/>
/// If is <see langword="null"/>, then there are no specific <see cref="Weeks"/>
/// </remarks>
///
public bool? IsExcludedWeeks { get; set; }
/// <summary>
/// The week numbers required for the correct display of the schedule.
/// <br/>
/// Whether there will be <see cref="Discipline"/> during the week or not depends on the <see cref="IsExcludedWeeks"/> property.
/// </summary>
/// <remarks>
/// To get the current week's number, use other queries.
/// </remarks>
public IEnumerable<int>? Weeks { get; set; }
/// <summary> /// <summary>
/// Gets or sets the type of occupation for the schedule entry. /// Gets or sets the type of occupation for the schedule entry.
/// </summary> /// </summary>

View File

@ -39,6 +39,29 @@ public class ScheduleResponse
[Required] [Required]
public required int DisciplineId { get; set; } public required int DisciplineId { get; set; }
/// <summary>
/// Gets or sets exclude or include weeks for a specific discipline.
/// </summary>
/// <remarks>
/// If is <see langword="true"/>, then the values in <see cref="Weeks"/> show the weeks when there will be no discipline.
/// <br/>
/// If is <see langword="false"/>, then the values in <see cref="Weeks"/> indicate the weeks during which a particular discipline will be studied.
/// <br/>
/// If is <see langword="null"/>, then there are no specific <see cref="Weeks"/>
/// </remarks>
///
public bool? IsExcludedWeeks { get; set; }
/// <summary>
/// The week numbers required for the correct display of the schedule.
/// <br/>
/// Whether there will be <see cref="Discipline"/> during the week or not depends on the <see cref="IsExcludedWeeks"/> property.
/// </summary>
/// <remarks>
/// To get the current week's number, use other queries.
/// </remarks>
public IEnumerable<int>? Weeks { get; set; }
/// <summary> /// <summary>
/// Gets or sets the type of occupation for the schedule entry. /// Gets or sets the type of occupation for the schedule entry.
/// </summary> /// </summary>

View File

@ -11,17 +11,7 @@ public class GetScheduleListQueryHandler(ILessonDbContext dbContext) : IRequestH
{ {
public async Task<ScheduleListVm> Handle(GetScheduleListQuery request, CancellationToken cancellationToken) public async Task<ScheduleListVm> Handle(GetScheduleListQuery request, CancellationToken cancellationToken)
{ {
var query = dbContext.Lessons var query = dbContext.Lessons.AsQueryable();
.Include(l => l.LessonAssociations)
.ThenInclude(la => la.LectureHall)
.ThenInclude(lh => lh!.Campus)
.Include(l => l.LessonAssociations)
.ThenInclude(la => la.Professor)
.Include(l => l.LessonAssociations)
.ThenInclude(la => la.TypeOfOccupation)
.Include(l => l.Group)
.Include(l => l.Discipline)
.AsQueryable();
if (request.IsEven != null) if (request.IsEven != null)
query = query.Where(l => l.IsEven == request.IsEven); query = query.Where(l => l.IsEven == request.IsEven);
@ -41,7 +31,17 @@ public class GetScheduleListQueryHandler(ILessonDbContext dbContext) : IRequestH
l.LessonAssociations!.Any(la => l.LessonAssociations!.Any(la =>
la.ProfessorId != null && request.ProfessorIds.Contains(la.ProfessorId.Value))); la.ProfessorId != null && request.ProfessorIds.Contains(la.ProfessorId.Value)));
var data = await query.ToArrayAsync(cancellationToken); var data = await query
.Include(lesson => lesson.Discipline!)
.Include(lesson => lesson.SpecificWeeks)
.Include(lesson => lesson.Group!)
.Include(lesson => lesson.LessonAssociations!)
.ThenInclude(lessonAssociation => lessonAssociation.TypeOfOccupation!)
.Include(lesson => lesson.LessonAssociations!)
.ThenInclude(lessonAssociation => lessonAssociation.Professor)
.Include(lesson => lesson.LessonAssociations!)
.ThenInclude(lessonAssociation => lessonAssociation.LectureHall)
.ThenInclude(lectureHall => lectureHall!.Campus).ToListAsync(cancellationToken);
var result = data.Select(l => new ScheduleLookupDto() var result = data.Select(l => new ScheduleLookupDto()
{ {
@ -55,6 +55,9 @@ public class GetScheduleListQueryHandler(ILessonDbContext dbContext) : IRequestH
Discipline = l.Discipline!.Name, Discipline = l.Discipline!.Name,
DisciplineId = l.DisciplineId, DisciplineId = l.DisciplineId,
IsExcludedWeeks = l.IsExcludedWeeks,
Weeks = l.SpecificWeeks?.Select(w => w.WeekNumber),
Group = l.Group!.Name, Group = l.Group!.Name,
GroupId = l.GroupId, GroupId = l.GroupId,
@ -72,7 +75,6 @@ public class GetScheduleListQueryHandler(ILessonDbContext dbContext) : IRequestH
.Where(la => la.LectureHall?.Campus != null) .Where(la => la.LectureHall?.Campus != null)
.Select(la => la.LectureHall?.CampusId), .Select(la => la.LectureHall?.CampusId),
Professors = l.LessonAssociations! Professors = l.LessonAssociations!
.Where(la => !string.IsNullOrEmpty(la.Professor?.Name)) .Where(la => !string.IsNullOrEmpty(la.Professor?.Name))
.Select(la => la.Professor?.Name), .Select(la => la.Professor?.Name),

View File

@ -33,6 +33,16 @@ public class ScheduleLookupDto
/// </summary> /// </summary>
public required int DisciplineId { get; set; } public required int DisciplineId { get; set; }
/// <summary>
/// Gets or sets exclude or include weeks for a specific discipline.
/// </summary>
public bool? IsExcludedWeeks { get; set; }
/// <summary>
/// The week numbers required for the correct display of the schedule.
/// </summary>
public IEnumerable<int>? Weeks { get; set; }
/// <summary> /// <summary>
/// Gets or sets the name of the group. /// Gets or sets the name of the group.
/// </summary> /// </summary>

View File

@ -60,6 +60,8 @@ public class ScheduleController(IMediator mediator) : BaseControllerV1
IsEven = s.IsEven, IsEven = s.IsEven,
Discipline = s.Discipline, Discipline = s.Discipline,
DisciplineId = s.DisciplineId, DisciplineId = s.DisciplineId,
IsExcludedWeeks = s.IsExcludedWeeks,
Weeks = s.Weeks,
TypeOfOccupations = s.TypeOfOccupations, TypeOfOccupations = s.TypeOfOccupations,
Group = s.Group, Group = s.Group,
GroupId = s.GroupId, GroupId = s.GroupId,
@ -117,6 +119,8 @@ public class ScheduleController(IMediator mediator) : BaseControllerV1
IsEven = g.IsEven, IsEven = g.IsEven,
Discipline = g.Discipline, Discipline = g.Discipline,
DisciplineId = g.DisciplineId, DisciplineId = g.DisciplineId,
IsExcludedWeeks = g.IsExcludedWeeks,
Weeks = g.Weeks,
TypeOfOccupations = g.TypeOfOccupations, TypeOfOccupations = g.TypeOfOccupations,
LectureHalls = g.LectureHalls, LectureHalls = g.LectureHalls,
LectureHallsId = g.LectureHallsId, LectureHallsId = g.LectureHallsId,
@ -176,6 +180,8 @@ public class ScheduleController(IMediator mediator) : BaseControllerV1
IsEven = p.IsEven, IsEven = p.IsEven,
Discipline = p.Discipline, Discipline = p.Discipline,
DisciplineId = p.DisciplineId, DisciplineId = p.DisciplineId,
IsExcludedWeeks = p.IsExcludedWeeks,
Weeks = p.Weeks,
TypeOfOccupations = p.TypeOfOccupations, TypeOfOccupations = p.TypeOfOccupations,
Group = p.Group, Group = p.Group,
GroupId = p.GroupId, GroupId = p.GroupId,
@ -235,6 +241,8 @@ public class ScheduleController(IMediator mediator) : BaseControllerV1
IsEven = l.IsEven, IsEven = l.IsEven,
Discipline = l.Discipline, Discipline = l.Discipline,
DisciplineId = l.DisciplineId, DisciplineId = l.DisciplineId,
IsExcludedWeeks = l.IsExcludedWeeks,
Weeks = l.Weeks,
TypeOfOccupations = l.TypeOfOccupations, TypeOfOccupations = l.TypeOfOccupations,
Group = l.Group, Group = l.Group,
GroupId = l.GroupId, GroupId = l.GroupId,