refactor: provide single response for schedule

This commit is contained in:
Polianin Nikita 2024-06-10 21:59:34 +03:00
parent 993e66a084
commit 4222e4702f
6 changed files with 33 additions and 651 deletions

View File

@ -1,106 +0,0 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
namespace Mirea.Api.Dto.Responses.Schedule;
/// <summary>
/// Represents information about a specific schedule entry for a professor.
/// </summary>
public class DisciplineScheduleInfo
{
/// <summary>
/// Gets or sets the day of the week for the schedule entry.
/// </summary>
[Required]
public DayOfWeek DayOfWeek { get; set; }
/// <summary>
/// Gets or sets the pair number for the schedule entry.
/// </summary>
[Required]
public int PairNumber { get; set; }
/// <summary>
/// Gets or sets a value indicating whether the pair is on an even week.
/// </summary>
[Required]
public bool IsEven { get; set; }
/// <summary>
/// Gets or sets the type of occupation for the schedule entry.
/// </summary>
[Required]
public required IEnumerable<string> TypeOfOccupation { get; set; }
/// <summary>
/// Gets or sets the names of the group for the schedule entry.
/// </summary>
[Required]
public required string Group { get; set; }
/// <summary>
/// Gets or sets the IDs of the group for the schedule entry.
/// </summary>
[Required]
public required int GroupId { get; set; }
/// <summary>
/// Gets or sets the names of the lecture halls for the schedule entry.
/// </summary>
public required IEnumerable<string?> LectureHalls { get; set; }
/// <summary>
/// Gets or sets the IDs of the lecture halls for the schedule entry.
/// </summary>
public required IEnumerable<int?> LectureHallsId { get; set; }
/// <summary>
/// Gets or sets the names of the professors for the schedule entry.
/// </summary>
public required IEnumerable<string?> Professors { get; set; }
/// <summary>
/// Gets or sets the IDs of the professors for the schedule entry.
/// </summary>
public required IEnumerable<int?> ProfessorsId { get; set; }
/// <summary>
/// Gets or sets the names of the campuses for the schedule entry.
/// </summary>
public required IEnumerable<string?> Campus { get; set; }
/// <summary>
/// Gets or sets the IDs of the campuses for the schedule entry.
/// </summary>
public required IEnumerable<int?> CampusId { get; set; }
/// <summary>
/// Gets or sets the links to online meetings for the schedule entry.
/// </summary>
public required IEnumerable<string?> LinkToMeet { get; set; }
}
/// <summary>
/// Represents a response containing schedule information for a professor.
/// </summary>
public class DisciplineScheduleResponse
{
/// <summary>
/// Gets or sets the name of the discipline.
/// </summary>
[Required]
public required string Discipline { get; set; }
/// <summary>
/// Gets or sets the ID of the discipline.
/// </summary>
[Required]
public required int DisciplineId { get; set; }
/// <summary>
/// Gets or sets the schedules for the professor.
/// </summary>
[Required]
public required IEnumerable<DisciplineScheduleInfo> Schedules { get; set; }
}

View File

@ -1,129 +0,0 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
namespace Mirea.Api.Dto.Responses.Schedule;
/// <summary>
/// Represents information about a specific schedule entry for a group.
/// </summary>
public class GroupScheduleInfo
{
/// <summary>
/// Gets or sets the day of the week for the schedule entry.
/// </summary>
[Required]
public DayOfWeek DayOfWeek { get; set; }
/// <summary>
/// Gets or sets the pair number for the schedule entry.
/// </summary>
[Required]
public int PairNumber { get; set; }
/// <summary>
/// Gets or sets a value indicating whether the pair is on an even week.
/// </summary>
[Required]
public bool IsEven { get; set; }
/// <summary>
/// Gets or sets the name of the discipline for the schedule entry.
/// </summary>
[Required]
public required string Discipline { get; set; }
/// <summary>
/// Gets or sets the ID of the discipline for the schedule entry.
/// </summary>
[Required]
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>
/// Gets or sets the type of occupation for the schedule entry.
/// </summary>
[Required]
public required IEnumerable<string> TypeOfOccupations { get; set; }
/// <summary>
/// Gets or sets the names of the lecture halls for the schedule entry.
/// </summary>
public required IEnumerable<string?> LectureHalls { get; set; }
/// <summary>
/// Gets or sets the IDs of the lecture halls for the schedule entry.
/// </summary>
public required IEnumerable<int?> LectureHallsId { get; set; }
/// <summary>
/// Gets or sets the names of the professors for the schedule entry.
/// </summary>
public required IEnumerable<string?> Professors { get; set; }
/// <summary>
/// Gets or sets the IDs of the professors for the schedule entry.
/// </summary>
public required IEnumerable<int?> ProfessorsId { get; set; }
/// <summary>
/// Gets or sets the names of the campuses for the schedule entry.
/// </summary>
public required IEnumerable<string?> Campus { get; set; }
/// <summary>
/// Gets or sets the IDs of the campuses for the schedule entry.
/// </summary>
public required IEnumerable<int?> CampusId { get; set; }
/// <summary>
/// Gets or sets the links to online meetings for the schedule entry.
/// </summary>
public required IEnumerable<string?> LinkToMeet { get; set; }
}
/// <summary>
/// Represents a response containing schedule information for a group.
/// </summary>
public class GroupScheduleResponse
{
/// <summary>
/// Gets or sets the name of the group.
/// </summary>
[Required]
public required string Group { get; set; }
/// <summary>
/// Gets or sets the ID of the group.
/// </summary>
[Required]
public required int GroupId { get; set; }
/// <summary>
/// Gets or sets the schedules for the group.
/// </summary>
[Required]
public required IEnumerable<GroupScheduleInfo> Schedules { get; set; }
}

View File

@ -1,128 +0,0 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
namespace Mirea.Api.Dto.Responses.Schedule;
/// <summary>
/// Represents information about a specific schedule entry for a lecture hall.
/// </summary>
public class LectureHallScheduleInfo
{
/// <summary>
/// Gets or sets the day of the week for the schedule entry.
/// </summary>
[Required]
public DayOfWeek DayOfWeek { get; set; }
/// <summary>
/// Gets or sets the pair number for the schedule entry.
/// </summary>
[Required]
public int PairNumber { get; set; }
/// <summary>
/// Gets or sets a value indicating whether the pair is on an even week.
/// </summary>
[Required]
public bool IsEven { get; set; }
/// <summary>
/// Gets or sets the name of the discipline for the schedule entry.
/// </summary>
[Required]
public required string Discipline { get; set; }
/// <summary>
/// Gets or sets the ID of the discipline for the schedule entry.
/// </summary>
[Required]
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>
/// Gets or sets the type of occupation for the schedule entry.
/// </summary>
[Required]
public required IEnumerable<string> TypeOfOccupations { get; set; }
/// <summary>
/// Gets or sets the names of the group for the schedule entry.
/// </summary>
[Required]
public required string Group { get; set; }
/// <summary>
/// Gets or sets the IDs of the group for the schedule entry.
/// </summary>
[Required]
public required int GroupId { get; set; }
/// <summary>
/// Gets or sets the names of the campuses for the schedule entry.
/// </summary>
public required IEnumerable<string?> Campus { get; set; }
/// <summary>
/// Gets or sets the IDs of the campuses for the schedule entry.
/// </summary>
public required IEnumerable<int?> CampusId { get; set; }
/// <summary>
/// Gets or sets the names of the professors for the schedule entry.
/// </summary>
public required IEnumerable<string?> Professors { get; set; }
/// <summary>
/// Gets or sets the IDs of the professors for the schedule entry.
/// </summary>
public required IEnumerable<int?> ProfessorsId { get; set; }
/// <summary>
/// Gets or sets the links to online meetings for the schedule entry.
/// </summary>
public required IEnumerable<string?> LinkToMeet { get; set; }
}
/// <summary>
/// Represents a response containing schedule information for a lecture hall.
/// </summary>
public class LectureHallScheduleResponse
{
/// <summary>
/// Gets or sets the names of the lecture halls.
/// </summary>
public required string LectureHalls { get; set; }
/// <summary>
/// Gets or sets the IDs of the lecture halls.
/// </summary>
public required int LectureHallsId { get; set; }
/// <summary>
/// Gets or sets the schedules for the lecture hall.
/// </summary>
[Required]
public required IEnumerable<LectureHallScheduleInfo> Schedules { get; set; }
}

View File

@ -1,131 +0,0 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
namespace Mirea.Api.Dto.Responses.Schedule;
/// <summary>
/// Represents information about a specific schedule entry for a professor.
/// </summary>
public class ProfessorScheduleInfo
{
/// <summary>
/// Gets or sets the day of the week for the schedule entry.
/// </summary>
[Required]
public DayOfWeek DayOfWeek { get; set; }
/// <summary>
/// Gets or sets the pair number for the schedule entry.
/// </summary>
[Required]
public int PairNumber { get; set; }
/// <summary>
/// Gets or sets a value indicating whether the pair is on an even week.
/// </summary>
[Required]
public bool IsEven { get; set; }
/// <summary>
/// Gets or sets the name of the discipline for the schedule entry.
/// </summary>
[Required]
public required string Discipline { get; set; }
/// <summary>
/// Gets or sets the ID of the discipline for the schedule entry.
/// </summary>
[Required]
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>
/// Gets or sets the type of occupation for the schedule entry.
/// </summary>
[Required]
public required IEnumerable<string> TypeOfOccupations { get; set; }
/// <summary>
/// Gets or sets the names of the group for the schedule entry.
/// </summary>
[Required]
public required string Group { get; set; }
/// <summary>
/// Gets or sets the IDs of the group for the schedule entry.
/// </summary>
[Required]
public required int GroupId { get; set; }
/// <summary>
/// Gets or sets the names of the lecture halls for the schedule entry.
/// </summary>
public required IEnumerable<string?> LectureHalls { get; set; }
/// <summary>
/// Gets or sets the IDs of the lecture halls for the schedule entry.
/// </summary>
public required IEnumerable<int?> LectureHallsId { get; set; }
/// <summary>
/// Gets or sets the names of the campuses for the schedule entry.
/// </summary>
public required IEnumerable<string?> Campus { get; set; }
/// <summary>
/// Gets or sets the IDs of the campuses for the schedule entry.
/// </summary>
public required IEnumerable<int?> CampusId { get; set; }
/// <summary>
/// Gets or sets the links to online meetings for the schedule entry.
/// </summary>
public required IEnumerable<string?> LinkToMeet { get; set; }
}
/// <summary>
/// Represents a response containing schedule information for a professor.
/// </summary>
public class ProfessorScheduleResponse
{
/// <summary>
/// Gets or sets the name of the professor.
/// </summary>
[Required]
public required string Professor { get; set; }
/// <summary>
/// Gets or sets the ID of the professor.
/// </summary>
[Required]
public required int ProfessorId { get; set; }
/// <summary>
/// Gets or sets the schedules for the professor.
/// </summary>
[Required]
public required IEnumerable<ProfessorScheduleInfo> Schedules { get; set; }
}

View File

@ -2,7 +2,7 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations;
namespace Mirea.Api.Dto.Responses.Schedule; namespace Mirea.Api.Dto.Responses;
/// <summary> /// <summary>
/// Represents a response object containing schedule information. /// Represents a response object containing schedule information.
@ -50,8 +50,8 @@ public class ScheduleResponse
/// If is <see langword="null"/>, then there are no specific <see cref="Weeks"/> /// If is <see langword="null"/>, then there are no specific <see cref="Weeks"/>
/// </remarks> /// </remarks>
/// ///
public bool? IsExcludedWeeks { get; set; } public bool? IsExcludedWeeks { get; set; }
/// <summary> /// <summary>
/// The week numbers required for the correct display of the schedule. /// The week numbers required for the correct display of the schedule.
/// <br/> /// <br/>

View File

@ -6,7 +6,6 @@ using Mirea.Api.DataAccess.Application.Cqrs.Schedule.Queries.GetScheduleList;
using Mirea.Api.Dto.Common; using Mirea.Api.Dto.Common;
using Mirea.Api.Dto.Requests; using Mirea.Api.Dto.Requests;
using Mirea.Api.Dto.Responses; using Mirea.Api.Dto.Responses;
using Mirea.Api.Dto.Responses.Schedule;
using Mirea.Api.Endpoint.Common.Attributes; using Mirea.Api.Endpoint.Common.Attributes;
using Mirea.Api.Endpoint.Common.Services; using Mirea.Api.Endpoint.Common.Services;
using Mirea.Api.Endpoint.Configuration.General; using Mirea.Api.Endpoint.Configuration.General;
@ -53,7 +52,7 @@ public class ScheduleController(IMediator mediator, IOptionsSnapshot<GeneralConf
}); });
} }
var result = (await mediator.Send(new GetScheduleListQuery() var result = (await mediator.Send(new GetScheduleListQuery
{ {
IsEven = request.IsEven, IsEven = request.IsEven,
DisciplineIds = request.Disciplines, DisciplineIds = request.Disciplines,
@ -64,7 +63,7 @@ public class ScheduleController(IMediator mediator, IOptionsSnapshot<GeneralConf
if (result.Count == 0) NoContent(); if (result.Count == 0) NoContent();
return Ok(result.Select(s => new ScheduleResponse() return Ok(result.Select(s => new ScheduleResponse
{ {
DayOfWeek = s.DayOfWeek, DayOfWeek = s.DayOfWeek,
PairNumber = s.PairNumber, PairNumber = s.PairNumber,
@ -84,7 +83,6 @@ public class ScheduleController(IMediator mediator, IOptionsSnapshot<GeneralConf
CampusId = s.CampusId, CampusId = s.CampusId,
LinkToMeet = s.LinkToMeet LinkToMeet = s.LinkToMeet
})); }));
} }
/// <summary> /// <summary>
@ -101,48 +99,19 @@ public class ScheduleController(IMediator mediator, IOptionsSnapshot<GeneralConf
[ProducesResponseType(StatusCodes.Status204NoContent)] [ProducesResponseType(StatusCodes.Status204NoContent)]
[BadRequestResponse] [BadRequestResponse]
[NotFoundResponse] [NotFoundResponse]
public async Task<ActionResult<GroupScheduleResponse>> GetByGroup(int id, public async Task<ActionResult<List<ScheduleResponse>>> GetByGroup(int id,
[FromQuery] bool? isEven = null, [FromQuery] bool? isEven = null,
[FromQuery] int[]? disciplines = null, [FromQuery] int[]? disciplines = null,
[FromQuery] int[]? professors = null, [FromQuery] int[]? professors = null,
[FromQuery] int[]? lectureHalls = null) [FromQuery] int[]? lectureHalls = null) =>
await Get(new ScheduleRequest
{
var result = (await mediator.Send(new GetScheduleListQuery()
{ {
Disciplines = disciplines,
IsEven = isEven, IsEven = isEven,
DisciplineIds = disciplines, Groups = [id],
GroupIds = [id], Professors = professors,
LectureHallIds = lectureHalls, LectureHalls = lectureHalls
ProfessorIds = professors
})).Schedules;
if (result.Count == 0) NoContent();
return Ok(new GroupScheduleResponse()
{
Group = result[0].Group,
GroupId = result[0].GroupId,
Schedules = result.Select(g => new GroupScheduleInfo()
{
DayOfWeek = g.DayOfWeek,
PairNumber = g.PairNumber,
IsEven = g.IsEven,
Discipline = g.Discipline,
DisciplineId = g.DisciplineId,
IsExcludedWeeks = g.IsExcludedWeeks,
Weeks = g.Weeks,
TypeOfOccupations = g.TypeOfOccupations,
LectureHalls = g.LectureHalls,
LectureHallsId = g.LectureHallsId,
Professors = g.Professors,
ProfessorsId = g.ProfessorsId,
Campus = g.Campus,
CampusId = g.CampusId,
LinkToMeet = g.LinkToMeet
})
}); });
}
/// <summary> /// <summary>
/// Retrieves schedules for a specific professor based on various filters. /// Retrieves schedules for a specific professor based on various filters.
@ -158,52 +127,19 @@ public class ScheduleController(IMediator mediator, IOptionsSnapshot<GeneralConf
[ProducesResponseType(StatusCodes.Status204NoContent)] [ProducesResponseType(StatusCodes.Status204NoContent)]
[BadRequestResponse] [BadRequestResponse]
[NotFoundResponse] [NotFoundResponse]
public async Task<ActionResult<ProfessorScheduleResponse>> GetByProfessor(int id, public async Task<ActionResult<List<ScheduleResponse>>> GetByProfessor(int id,
[FromQuery] bool? isEven = null, [FromQuery] bool? isEven = null,
[FromQuery] int[]? disciplines = null, [FromQuery] int[]? disciplines = null,
[FromQuery] int[]? groups = null, [FromQuery] int[]? groups = null,
[FromQuery] int[]? lectureHalls = null) [FromQuery] int[]? lectureHalls = null) =>
await Get(new ScheduleRequest
{
var result = (await mediator.Send(new GetScheduleListQuery()
{ {
Disciplines = disciplines,
IsEven = isEven, IsEven = isEven,
DisciplineIds = disciplines, Groups = groups,
GroupIds = groups, Professors = [id],
LectureHallIds = lectureHalls, LectureHalls = lectureHalls
ProfessorIds = [id]
})).Schedules;
if (result.Count == 0) NoContent();
return Ok(new ProfessorScheduleResponse()
{
Professor = result.Select(professor =>
professor.Professors.FirstOrDefault(x => !string.IsNullOrEmpty(x))
).First()!,
ProfessorId = result.Select(professor =>
professor.ProfessorsId.FirstOrDefault(x => x != null)
).First()!.Value,
Schedules = result.Select(p => new ProfessorScheduleInfo()
{
DayOfWeek = p.DayOfWeek,
PairNumber = p.PairNumber,
IsEven = p.IsEven,
Discipline = p.Discipline,
DisciplineId = p.DisciplineId,
IsExcludedWeeks = p.IsExcludedWeeks,
Weeks = p.Weeks,
TypeOfOccupations = p.TypeOfOccupations,
Group = p.Group,
GroupId = p.GroupId,
LectureHalls = p.LectureHalls,
LectureHallsId = p.LectureHallsId,
Campus = p.Campus,
CampusId = p.CampusId,
LinkToMeet = p.LinkToMeet
})
}); });
}
/// <summary> /// <summary>
/// Retrieves schedules for a specific lecture hall based on various filters. /// Retrieves schedules for a specific lecture hall based on various filters.
@ -219,52 +155,19 @@ public class ScheduleController(IMediator mediator, IOptionsSnapshot<GeneralConf
[ProducesResponseType(StatusCodes.Status204NoContent)] [ProducesResponseType(StatusCodes.Status204NoContent)]
[BadRequestResponse] [BadRequestResponse]
[NotFoundResponse] [NotFoundResponse]
public async Task<ActionResult<LectureHallScheduleResponse>> GetByLectureHall(int id, public async Task<ActionResult<List<ScheduleResponse>>> GetByLectureHall(int id,
[FromQuery] bool? isEven = null, [FromQuery] bool? isEven = null,
[FromQuery] int[]? disciplines = null, [FromQuery] int[]? disciplines = null,
[FromQuery] int[]? groups = null, [FromQuery] int[]? groups = null,
[FromQuery] int[]? professors = null) [FromQuery] int[]? professors = null) =>
await Get(new ScheduleRequest
{
var result = (await mediator.Send(new GetScheduleListQuery()
{ {
Disciplines = disciplines,
IsEven = isEven, IsEven = isEven,
DisciplineIds = disciplines, Groups = groups,
GroupIds = groups, Professors = professors,
LectureHallIds = [id], LectureHalls = [id]
ProfessorIds = professors
})).Schedules;
if (result.Count == 0) NoContent();
return Ok(new LectureHallScheduleResponse()
{
LectureHalls = result.Select(lectureHall =>
lectureHall.LectureHalls.FirstOrDefault(x => !string.IsNullOrEmpty(x))
).First()!,
LectureHallsId = result.Select(lectureHall =>
lectureHall.LectureHallsId.FirstOrDefault(x => x != null)
).First()!.Value,
Schedules = result.Select(l => new LectureHallScheduleInfo()
{
DayOfWeek = l.DayOfWeek,
PairNumber = l.PairNumber,
IsEven = l.IsEven,
Discipline = l.Discipline,
DisciplineId = l.DisciplineId,
IsExcludedWeeks = l.IsExcludedWeeks,
Weeks = l.Weeks,
TypeOfOccupations = l.TypeOfOccupations,
Group = l.Group,
GroupId = l.GroupId,
Professors = l.Professors,
ProfessorsId = l.ProfessorsId,
Campus = l.Campus,
CampusId = l.CampusId,
LinkToMeet = l.LinkToMeet
})
}); });
}
/// <summary> /// <summary>
/// Retrieves schedules for a specific discipline based on various filters. /// Retrieves schedules for a specific discipline based on various filters.
@ -280,44 +183,17 @@ public class ScheduleController(IMediator mediator, IOptionsSnapshot<GeneralConf
[ProducesResponseType(StatusCodes.Status204NoContent)] [ProducesResponseType(StatusCodes.Status204NoContent)]
[BadRequestResponse] [BadRequestResponse]
[NotFoundResponse] [NotFoundResponse]
public async Task<ActionResult<DisciplineScheduleResponse>> GetByDiscipline(int id, public async Task<ActionResult<List<ScheduleResponse>>> GetByDiscipline(int id,
[FromQuery] bool? isEven = null, [FromQuery] bool? isEven = null,
[FromQuery] int[]? groups = null, [FromQuery] int[]? groups = null,
[FromQuery] int[]? professors = null, [FromQuery] int[]? professors = null,
[FromQuery] int[]? lectureHalls = null) [FromQuery] int[]? lectureHalls = null) =>
await Get(new ScheduleRequest
{
var result = (await mediator.Send(new GetScheduleListQuery()
{ {
Disciplines = [id],
IsEven = isEven, IsEven = isEven,
DisciplineIds = [id], Groups = groups,
GroupIds = groups, Professors = professors,
LectureHallIds = lectureHalls, LectureHalls = lectureHalls
ProfessorIds = professors
})).Schedules;
if (result.Count == 0) NoContent();
return Ok(new DisciplineScheduleResponse()
{
Discipline = result[0].Discipline,
DisciplineId = result[0].DisciplineId,
Schedules = result.Select(d => new DisciplineScheduleInfo()
{
DayOfWeek = d.DayOfWeek,
PairNumber = d.PairNumber,
IsEven = d.IsEven,
TypeOfOccupation = d.TypeOfOccupations,
Group = d.Group,
GroupId = d.GroupId,
LectureHalls = d.LectureHalls,
LectureHallsId = d.LectureHallsId,
Professors = d.Professors,
ProfessorsId = d.ProfessorsId,
Campus = d.Campus,
CampusId = d.CampusId,
LinkToMeet = d.LinkToMeet
})
}); });
} }
}