Add specific weeks of disciplines #10
@ -31,7 +31,7 @@ public class DisciplineScheduleInfo
|
|||||||
/// Gets or sets the type of occupation for the schedule entry.
|
/// Gets or sets the type of occupation for the schedule entry.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[Required]
|
[Required]
|
||||||
public required string TypeOfOccupation { get; set; }
|
public required IEnumerable<string> TypeOfOccupation { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or sets the names of the group for the schedule entry.
|
/// Gets or sets the names of the group for the schedule entry.
|
||||||
|
@ -39,11 +39,34 @@ 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>
|
||||||
[Required]
|
[Required]
|
||||||
public required string TypeOfOccupation { get; set; }
|
public required IEnumerable<string> TypeOfOccupations { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or sets the names of the lecture halls for the schedule entry.
|
/// Gets or sets the names of the lecture halls for the schedule entry.
|
||||||
|
@ -39,11 +39,34 @@ 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>
|
||||||
[Required]
|
[Required]
|
||||||
public required string TypeOfOccupation { get; set; }
|
public required IEnumerable<string> TypeOfOccupations { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or sets the names of the group for the schedule entry.
|
/// Gets or sets the names of the group for the schedule entry.
|
||||||
|
@ -39,11 +39,34 @@ 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>
|
||||||
[Required]
|
[Required]
|
||||||
public required string TypeOfOccupation { get; set; }
|
public required IEnumerable<string> TypeOfOccupations { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or sets the names of the group for the schedule entry.
|
/// Gets or sets the names of the group for the schedule entry.
|
||||||
|
@ -39,11 +39,34 @@ 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>
|
||||||
[Required]
|
[Required]
|
||||||
public required string TypeOfOccupation { get; set; }
|
public required IEnumerable<string> TypeOfOccupations { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or sets the name of the group for the schedule entry.
|
/// Gets or sets the name of the group for the schedule entry.
|
||||||
|
@ -11,15 +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.Include(l => l.LessonAssociations)
|
var query = dbContext.Lessons.AsQueryable();
|
||||||
.ThenInclude(la => la.LectureHall)
|
|
||||||
.ThenInclude(lh => lh!.Campus)
|
|
||||||
.Include(l => l.LessonAssociations)
|
|
||||||
.ThenInclude(la => la.Professor)
|
|
||||||
.Include(l => l.Group)
|
|
||||||
.Include(l => l.TypeOfOccupation)
|
|
||||||
.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);
|
||||||
@ -39,18 +31,33 @@ 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()
|
||||||
{
|
{
|
||||||
DayOfWeek = l.DayOfWeek,
|
DayOfWeek = l.DayOfWeek,
|
||||||
PairNumber = l.PairNumber,
|
PairNumber = l.PairNumber,
|
||||||
IsEven = l.IsEven,
|
IsEven = l.IsEven,
|
||||||
TypeOfOccupation = l.TypeOfOccupation!.ShortName,
|
TypeOfOccupations = l.LessonAssociations!
|
||||||
|
.Where(la => !string.IsNullOrEmpty(la.TypeOfOccupation?.ShortName))
|
||||||
|
.Select(la => la.TypeOfOccupation!.ShortName),
|
||||||
|
|
||||||
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,
|
||||||
|
|
||||||
@ -68,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),
|
||||||
|
@ -34,9 +34,14 @@ public class ScheduleLookupDto
|
|||||||
public required int DisciplineId { get; set; }
|
public required int DisciplineId { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or sets the type of occupation.
|
/// Gets or sets exclude or include weeks for a specific discipline.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public required string TypeOfOccupation { get; set; }
|
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.
|
||||||
@ -48,6 +53,11 @@ public class ScheduleLookupDto
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public required int GroupId { get; set; }
|
public required int GroupId { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets the type of occupation.
|
||||||
|
/// </summary>
|
||||||
|
public required IEnumerable<string> TypeOfOccupations { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or sets the names of the lecture halls.
|
/// Gets or sets the names of the lecture halls.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -0,0 +1,9 @@
|
|||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using Mirea.Api.DataAccess.Domain.Schedule;
|
||||||
|
|
||||||
|
namespace Mirea.Api.DataAccess.Application.Interfaces.DbContexts.Schedule;
|
||||||
|
|
||||||
|
public interface ISpecificWeekDbContext : IDbContextBase
|
||||||
|
{
|
||||||
|
DbSet<SpecificWeek> SpecificWeeks { get; set; }
|
||||||
|
}
|
@ -9,13 +9,13 @@ public class Lesson
|
|||||||
public bool IsEven { get; set; }
|
public bool IsEven { get; set; }
|
||||||
public DayOfWeek DayOfWeek { get; set; }
|
public DayOfWeek DayOfWeek { get; set; }
|
||||||
public int PairNumber { get; set; }
|
public int PairNumber { get; set; }
|
||||||
|
public bool? IsExcludedWeeks { get; set; }
|
||||||
|
|
||||||
public int GroupId { get; set; }
|
public int GroupId { get; set; }
|
||||||
public Group? Group { get; set; }
|
public Group? Group { get; set; }
|
||||||
public int TypeOfOccupationId { get; set; }
|
|
||||||
public TypeOfOccupation? TypeOfOccupation { get; set; }
|
|
||||||
public int DisciplineId { get; set; }
|
public int DisciplineId { get; set; }
|
||||||
public Discipline? Discipline { get; set; }
|
public Discipline? Discipline { get; set; }
|
||||||
|
|
||||||
public List<LessonAssociation>? LessonAssociations { get; set; }
|
public List<LessonAssociation>? LessonAssociations { get; set; }
|
||||||
|
public List<SpecificWeek>? SpecificWeeks { get; set; }
|
||||||
}
|
}
|
@ -5,6 +5,8 @@ public class LessonAssociation
|
|||||||
public int Id { get; set; }
|
public int Id { get; set; }
|
||||||
public string? LinkToMeet { get; set; }
|
public string? LinkToMeet { get; set; }
|
||||||
|
|
||||||
|
public int TypeOfOccupationId { get; set; }
|
||||||
|
public TypeOfOccupation? TypeOfOccupation { get; set; }
|
||||||
public int LessonId { get; set; }
|
public int LessonId { get; set; }
|
||||||
public Lesson? Lesson { get; set; }
|
public Lesson? Lesson { get; set; }
|
||||||
public int? ProfessorId { get; set; }
|
public int? ProfessorId { get; set; }
|
||||||
|
10
Domain/Schedule/SpecificWeek.cs
Normal file
10
Domain/Schedule/SpecificWeek.cs
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
namespace Mirea.Api.DataAccess.Domain.Schedule;
|
||||||
|
|
||||||
|
public class SpecificWeek
|
||||||
|
{
|
||||||
|
public int Id { get; set; }
|
||||||
|
public int WeekNumber { get; set; }
|
||||||
|
|
||||||
|
public int LessonId { get; set; }
|
||||||
|
public Lesson? Lesson { get; set; }
|
||||||
|
}
|
@ -6,7 +6,6 @@ public class TypeOfOccupation
|
|||||||
{
|
{
|
||||||
public int Id { get; set; }
|
public int Id { get; set; }
|
||||||
public required string ShortName { get; set; }
|
public required string ShortName { get; set; }
|
||||||
public string? FullName { get; set; }
|
|
||||||
|
|
||||||
public List<Lesson>? Lessons { get; set; }
|
public List<LessonAssociation>? Lessons { get; set; }
|
||||||
}
|
}
|
@ -27,10 +27,10 @@ public class ScheduleController(IMediator mediator) : BaseControllerV1
|
|||||||
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.Any()) &&
|
if ((request.Groups == null || request.Groups.Length == 0) &&
|
||||||
(request.Disciplines == null || !request.Disciplines.Any()) &&
|
(request.Disciplines == null || request.Disciplines.Length == 0) &&
|
||||||
(request.Professors == null || !request.Professors.Any()) &&
|
(request.Professors == null || request.Professors.Length == 0) &&
|
||||||
(request.LectureHalls == null || !request.LectureHalls.Any()))
|
(request.LectureHalls == null || request.LectureHalls.Length == 0))
|
||||||
{
|
{
|
||||||
return BadRequest(new ErrorResponse()
|
return BadRequest(new ErrorResponse()
|
||||||
{
|
{
|
||||||
@ -60,7 +60,9 @@ public class ScheduleController(IMediator mediator) : BaseControllerV1
|
|||||||
IsEven = s.IsEven,
|
IsEven = s.IsEven,
|
||||||
Discipline = s.Discipline,
|
Discipline = s.Discipline,
|
||||||
DisciplineId = s.DisciplineId,
|
DisciplineId = s.DisciplineId,
|
||||||
TypeOfOccupation = s.TypeOfOccupation,
|
IsExcludedWeeks = s.IsExcludedWeeks,
|
||||||
|
Weeks = s.Weeks,
|
||||||
|
TypeOfOccupations = s.TypeOfOccupations,
|
||||||
Group = s.Group,
|
Group = s.Group,
|
||||||
GroupId = s.GroupId,
|
GroupId = s.GroupId,
|
||||||
LectureHalls = s.LectureHalls,
|
LectureHalls = s.LectureHalls,
|
||||||
@ -117,7 +119,9 @@ public class ScheduleController(IMediator mediator) : BaseControllerV1
|
|||||||
IsEven = g.IsEven,
|
IsEven = g.IsEven,
|
||||||
Discipline = g.Discipline,
|
Discipline = g.Discipline,
|
||||||
DisciplineId = g.DisciplineId,
|
DisciplineId = g.DisciplineId,
|
||||||
TypeOfOccupation = g.TypeOfOccupation,
|
IsExcludedWeeks = g.IsExcludedWeeks,
|
||||||
|
Weeks = g.Weeks,
|
||||||
|
TypeOfOccupations = g.TypeOfOccupations,
|
||||||
LectureHalls = g.LectureHalls,
|
LectureHalls = g.LectureHalls,
|
||||||
LectureHallsId = g.LectureHallsId,
|
LectureHallsId = g.LectureHallsId,
|
||||||
Professors = g.Professors,
|
Professors = g.Professors,
|
||||||
@ -176,7 +180,9 @@ public class ScheduleController(IMediator mediator) : BaseControllerV1
|
|||||||
IsEven = p.IsEven,
|
IsEven = p.IsEven,
|
||||||
Discipline = p.Discipline,
|
Discipline = p.Discipline,
|
||||||
DisciplineId = p.DisciplineId,
|
DisciplineId = p.DisciplineId,
|
||||||
TypeOfOccupation = p.TypeOfOccupation,
|
IsExcludedWeeks = p.IsExcludedWeeks,
|
||||||
|
Weeks = p.Weeks,
|
||||||
|
TypeOfOccupations = p.TypeOfOccupations,
|
||||||
Group = p.Group,
|
Group = p.Group,
|
||||||
GroupId = p.GroupId,
|
GroupId = p.GroupId,
|
||||||
LectureHalls = p.LectureHalls,
|
LectureHalls = p.LectureHalls,
|
||||||
@ -235,7 +241,9 @@ public class ScheduleController(IMediator mediator) : BaseControllerV1
|
|||||||
IsEven = l.IsEven,
|
IsEven = l.IsEven,
|
||||||
Discipline = l.Discipline,
|
Discipline = l.Discipline,
|
||||||
DisciplineId = l.DisciplineId,
|
DisciplineId = l.DisciplineId,
|
||||||
TypeOfOccupation = l.TypeOfOccupation,
|
IsExcludedWeeks = l.IsExcludedWeeks,
|
||||||
|
Weeks = l.Weeks,
|
||||||
|
TypeOfOccupations = l.TypeOfOccupations,
|
||||||
Group = l.Group,
|
Group = l.Group,
|
||||||
GroupId = l.GroupId,
|
GroupId = l.GroupId,
|
||||||
Professors = l.Professors,
|
Professors = l.Professors,
|
||||||
@ -273,7 +281,7 @@ public class ScheduleController(IMediator mediator) : BaseControllerV1
|
|||||||
IsEven = isEven,
|
IsEven = isEven,
|
||||||
DisciplineIds = [id],
|
DisciplineIds = [id],
|
||||||
GroupIds = groups,
|
GroupIds = groups,
|
||||||
LectureHallIds = [id],
|
LectureHallIds = lectureHalls,
|
||||||
ProfessorIds = professors
|
ProfessorIds = professors
|
||||||
})).Schedules;
|
})).Schedules;
|
||||||
|
|
||||||
@ -288,7 +296,7 @@ public class ScheduleController(IMediator mediator) : BaseControllerV1
|
|||||||
DayOfWeek = d.DayOfWeek,
|
DayOfWeek = d.DayOfWeek,
|
||||||
PairNumber = d.PairNumber,
|
PairNumber = d.PairNumber,
|
||||||
IsEven = d.IsEven,
|
IsEven = d.IsEven,
|
||||||
TypeOfOccupation = d.TypeOfOccupation,
|
TypeOfOccupation = d.TypeOfOccupations,
|
||||||
Group = d.Group,
|
Group = d.Group,
|
||||||
GroupId = d.GroupId,
|
GroupId = d.GroupId,
|
||||||
LectureHalls = d.LectureHalls,
|
LectureHalls = d.LectureHalls,
|
||||||
|
17
Persistence/Contexts/Schedule/SpecificWeekDbContext.cs
Normal file
17
Persistence/Contexts/Schedule/SpecificWeekDbContext.cs
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using Mirea.Api.DataAccess.Application.Interfaces.DbContexts.Schedule;
|
||||||
|
using Mirea.Api.DataAccess.Domain.Schedule;
|
||||||
|
using Mirea.Api.DataAccess.Persistence.EntityTypeConfigurations.Schedule;
|
||||||
|
|
||||||
|
namespace Mirea.Api.DataAccess.Persistence.Contexts.Schedule;
|
||||||
|
|
||||||
|
public class SpecificWeekDbContext(DbContextOptions<SpecificWeekDbContext> options) : DbContext(options), ISpecificWeekDbContext
|
||||||
|
{
|
||||||
|
public DbSet<SpecificWeek> SpecificWeeks { get; set; } = null!;
|
||||||
|
|
||||||
|
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
||||||
|
{
|
||||||
|
modelBuilder.ApplyConfiguration(new SpecificWeekConfiguration());
|
||||||
|
base.OnModelCreating(modelBuilder);
|
||||||
|
}
|
||||||
|
}
|
@ -43,6 +43,7 @@ public static class DependencyInjection
|
|||||||
services.AddDbContext<ProfessorDbContext>(dbConfig);
|
services.AddDbContext<ProfessorDbContext>(dbConfig);
|
||||||
services.AddDbContext<LessonDbContext>(dbConfig);
|
services.AddDbContext<LessonDbContext>(dbConfig);
|
||||||
services.AddDbContext<TypeOfOccupationDbContext>(dbConfig);
|
services.AddDbContext<TypeOfOccupationDbContext>(dbConfig);
|
||||||
|
services.AddDbContext<SpecificWeekDbContext>(dbConfig);
|
||||||
|
|
||||||
services.AddDbContext<UberDbContext>(dbConfig);
|
services.AddDbContext<UberDbContext>(dbConfig);
|
||||||
}
|
}
|
||||||
@ -58,6 +59,7 @@ public static class DependencyInjection
|
|||||||
services.AddScoped<IProfessorDbContext>(provider => provider.GetService<ProfessorDbContext>()!);
|
services.AddScoped<IProfessorDbContext>(provider => provider.GetService<ProfessorDbContext>()!);
|
||||||
services.AddScoped<ILessonDbContext>(provider => provider.GetService<LessonDbContext>()!);
|
services.AddScoped<ILessonDbContext>(provider => provider.GetService<LessonDbContext>()!);
|
||||||
services.AddScoped<ITypeOfOccupationDbContext>(provider => provider.GetService<TypeOfOccupationDbContext>()!);
|
services.AddScoped<ITypeOfOccupationDbContext>(provider => provider.GetService<TypeOfOccupationDbContext>()!);
|
||||||
|
services.AddScoped<ISpecificWeekDbContext>(provider => provider.GetService<SpecificWeekDbContext>()!);
|
||||||
|
|
||||||
return services;
|
return services;
|
||||||
}
|
}
|
||||||
|
@ -18,6 +18,8 @@ public class LessonAssociationConfiguration : IEntityTypeConfiguration<LessonAss
|
|||||||
builder.Property(l => l.LessonId).HasColumnType("INTEGER").IsRequired();
|
builder.Property(l => l.LessonId).HasColumnType("INTEGER").IsRequired();
|
||||||
builder.Property(l => l.ProfessorId).HasColumnType("INTEGER");
|
builder.Property(l => l.ProfessorId).HasColumnType("INTEGER");
|
||||||
builder.Property(l => l.LectureHallId).HasColumnType("INTEGER");
|
builder.Property(l => l.LectureHallId).HasColumnType("INTEGER");
|
||||||
|
builder.Property(l => l.TypeOfOccupationId).HasColumnType("INTEGER").IsRequired();
|
||||||
|
|
||||||
|
|
||||||
builder
|
builder
|
||||||
.HasOne(l => l.Lesson)
|
.HasOne(l => l.Lesson)
|
||||||
@ -36,5 +38,11 @@ public class LessonAssociationConfiguration : IEntityTypeConfiguration<LessonAss
|
|||||||
.WithMany(l => l.LessonAssociations)
|
.WithMany(l => l.LessonAssociations)
|
||||||
.HasForeignKey(l => l.LectureHallId)
|
.HasForeignKey(l => l.LectureHallId)
|
||||||
.OnDelete(DeleteBehavior.SetNull);
|
.OnDelete(DeleteBehavior.SetNull);
|
||||||
|
|
||||||
|
builder
|
||||||
|
.HasOne(l => l.TypeOfOccupation)
|
||||||
|
.WithMany(t => t.Lessons)
|
||||||
|
.HasForeignKey(d => d.TypeOfOccupationId)
|
||||||
|
.OnDelete(DeleteBehavior.Cascade);
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -13,27 +13,20 @@ public class LessonConfiguration : IEntityTypeConfiguration<Lesson>
|
|||||||
builder.HasIndex(l => l.Id).IsUnique();
|
builder.HasIndex(l => l.Id).IsUnique();
|
||||||
builder.Property(l => l.Id).HasColumnType("INTEGER").IsRequired().ValueGeneratedOnAdd();
|
builder.Property(l => l.Id).HasColumnType("INTEGER").IsRequired().ValueGeneratedOnAdd();
|
||||||
|
|
||||||
builder.Property(l => l.IsEven).HasColumnType("BIT").IsRequired();
|
builder.Property(l => l.IsEven).HasColumnType("BOOLEAN").IsRequired();
|
||||||
builder.Property(l => l.DayOfWeek).HasColumnType("INTEGER").IsRequired();
|
builder.Property(l => l.DayOfWeek).HasColumnType("INTEGER").IsRequired();
|
||||||
builder.Property(l => l.PairNumber).HasColumnType("INTEGER").IsRequired();
|
builder.Property(l => l.PairNumber).HasColumnType("INTEGER").IsRequired();
|
||||||
|
builder.Property(l => l.IsExcludedWeeks).HasColumnType("BOOLEAN");
|
||||||
|
|
||||||
builder.Property(l => l.GroupId).HasColumnType("INTEGER").IsRequired();
|
builder.Property(l => l.GroupId).HasColumnType("INTEGER").IsRequired();
|
||||||
builder.Property(l => l.TypeOfOccupationId).HasColumnType("INTEGER").IsRequired();
|
|
||||||
builder.Property(l => l.DisciplineId).HasColumnType("INTEGER").IsRequired();
|
builder.Property(l => l.DisciplineId).HasColumnType("INTEGER").IsRequired();
|
||||||
|
|
||||||
|
|
||||||
builder
|
builder
|
||||||
.HasOne(l => l.Group)
|
.HasOne(l => l.Group)
|
||||||
.WithMany(g => g.Lessons)
|
.WithMany(g => g.Lessons)
|
||||||
.HasForeignKey(d => d.GroupId)
|
.HasForeignKey(d => d.GroupId)
|
||||||
.OnDelete(DeleteBehavior.Cascade);
|
.OnDelete(DeleteBehavior.Cascade);
|
||||||
|
|
||||||
builder
|
|
||||||
.HasOne(l => l.TypeOfOccupation)
|
|
||||||
.WithMany(t => t.Lessons)
|
|
||||||
.HasForeignKey(d => d.TypeOfOccupationId)
|
|
||||||
.OnDelete(DeleteBehavior.Cascade);
|
|
||||||
|
|
||||||
builder
|
builder
|
||||||
.HasOne(l => l.Discipline)
|
.HasOne(l => l.Discipline)
|
||||||
.WithMany(d => d.Lessons)
|
.WithMany(d => d.Lessons)
|
||||||
|
@ -0,0 +1,26 @@
|
|||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||||||
|
using Mirea.Api.DataAccess.Domain.Schedule;
|
||||||
|
|
||||||
|
namespace Mirea.Api.DataAccess.Persistence.EntityTypeConfigurations.Schedule;
|
||||||
|
|
||||||
|
public class SpecificWeekConfiguration : IEntityTypeConfiguration<SpecificWeek>
|
||||||
|
{
|
||||||
|
public void Configure(EntityTypeBuilder<SpecificWeek> builder)
|
||||||
|
{
|
||||||
|
builder.ToTable(nameof(SpecificWeek));
|
||||||
|
builder.HasKey(s => s.Id);
|
||||||
|
builder.HasIndex(s => s.Id).IsUnique();
|
||||||
|
builder.Property(s => s.Id).HasColumnType("INTEGER").IsRequired().ValueGeneratedOnAdd();
|
||||||
|
|
||||||
|
builder.Property(s => s.WeekNumber).HasColumnType("INTEGER").IsRequired();
|
||||||
|
|
||||||
|
builder.Property(s => s.LessonId).HasColumnType("INTEGER").IsRequired();
|
||||||
|
|
||||||
|
builder
|
||||||
|
.HasOne(s => s.Lesson)
|
||||||
|
.WithMany(l => l.SpecificWeeks)
|
||||||
|
.HasForeignKey(s => s.LessonId)
|
||||||
|
.OnDelete(DeleteBehavior.Cascade);
|
||||||
|
}
|
||||||
|
}
|
@ -14,6 +14,5 @@ public class TypeOfOccupationConfiguration : IEntityTypeConfiguration<TypeOfOccu
|
|||||||
builder.Property(t => t.Id).HasColumnType("INTEGER").IsRequired().ValueGeneratedOnAdd();
|
builder.Property(t => t.Id).HasColumnType("INTEGER").IsRequired().ValueGeneratedOnAdd();
|
||||||
|
|
||||||
builder.Property(t => t.ShortName).HasColumnType("TEXT").IsRequired().HasMaxLength(16);
|
builder.Property(t => t.ShortName).HasColumnType("TEXT").IsRequired().HasMaxLength(16);
|
||||||
builder.Property(t => t.FullName).HasColumnType("TEXT").HasMaxLength(64);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -15,6 +15,7 @@ public class UberDbContext(DbContextOptions<UberDbContext> options) : DbContext(
|
|||||||
public DbSet<Lesson> Lessons { get; set; } = null!;
|
public DbSet<Lesson> Lessons { get; set; } = null!;
|
||||||
public DbSet<Professor> Professors { get; set; } = null!;
|
public DbSet<Professor> Professors { get; set; } = null!;
|
||||||
public DbSet<TypeOfOccupation> TypeOfOccupations { get; set; } = null!;
|
public DbSet<TypeOfOccupation> TypeOfOccupations { get; set; } = null!;
|
||||||
|
public DbSet<SpecificWeek> SpecificWeeks { get; set; } = null!;
|
||||||
|
|
||||||
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
||||||
{
|
{
|
||||||
@ -27,6 +28,7 @@ public class UberDbContext(DbContextOptions<UberDbContext> options) : DbContext(
|
|||||||
modelBuilder.ApplyConfiguration(new ProfessorConfiguration());
|
modelBuilder.ApplyConfiguration(new ProfessorConfiguration());
|
||||||
modelBuilder.ApplyConfiguration(new LessonAssociationConfiguration());
|
modelBuilder.ApplyConfiguration(new LessonAssociationConfiguration());
|
||||||
modelBuilder.ApplyConfiguration(new TypeOfOccupationConfiguration());
|
modelBuilder.ApplyConfiguration(new TypeOfOccupationConfiguration());
|
||||||
|
modelBuilder.ApplyConfiguration(new SpecificWeekConfiguration());
|
||||||
|
|
||||||
base.OnModelCreating(modelBuilder);
|
base.OnModelCreating(modelBuilder);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user