Compare commits
No commits in common. "6716ee9cf09bfc807116f1cd759feeaba56b8394" and "ed0143cda1bfeaa5fa481ef2ba235a798215883d" have entirely different histories.
6716ee9cf0
...
ed0143cda1
@ -31,7 +31,7 @@ public class DisciplineScheduleInfo
|
||||
/// Gets or sets the type of occupation for the schedule entry.
|
||||
/// </summary>
|
||||
[Required]
|
||||
public required IEnumerable<string> TypeOfOccupation { get; set; }
|
||||
public required string TypeOfOccupation { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the names of the group for the schedule entry.
|
||||
|
@ -39,34 +39,11 @@ public class GroupScheduleInfo
|
||||
[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; }
|
||||
public required string TypeOfOccupation { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the names of the lecture halls for the schedule entry.
|
||||
|
@ -39,34 +39,11 @@ public class LectureHallScheduleInfo
|
||||
[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; }
|
||||
public required string TypeOfOccupation { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the names of the group for the schedule entry.
|
||||
|
@ -39,34 +39,11 @@ public class ProfessorScheduleInfo
|
||||
[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; }
|
||||
public required string TypeOfOccupation { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the names of the group for the schedule entry.
|
||||
|
@ -39,34 +39,11 @@ public class ScheduleResponse
|
||||
[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; }
|
||||
public required string TypeOfOccupation { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the name of the group for the schedule entry.
|
||||
|
@ -11,7 +11,15 @@ public class GetScheduleListQueryHandler(ILessonDbContext dbContext) : IRequestH
|
||||
{
|
||||
public async Task<ScheduleListVm> Handle(GetScheduleListQuery request, CancellationToken cancellationToken)
|
||||
{
|
||||
var query = dbContext.Lessons.AsQueryable();
|
||||
var query = dbContext.Lessons.Include(l => l.LessonAssociations)
|
||||
.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)
|
||||
query = query.Where(l => l.IsEven == request.IsEven);
|
||||
@ -31,33 +39,18 @@ public class GetScheduleListQueryHandler(ILessonDbContext dbContext) : IRequestH
|
||||
l.LessonAssociations!.Any(la =>
|
||||
la.ProfessorId != null && request.ProfessorIds.Contains(la.ProfessorId.Value)));
|
||||
|
||||
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 data = await query.ToArrayAsync(cancellationToken);
|
||||
|
||||
var result = data.Select(l => new ScheduleLookupDto()
|
||||
{
|
||||
DayOfWeek = l.DayOfWeek,
|
||||
PairNumber = l.PairNumber,
|
||||
IsEven = l.IsEven,
|
||||
TypeOfOccupations = l.LessonAssociations!
|
||||
.Where(la => !string.IsNullOrEmpty(la.TypeOfOccupation?.ShortName))
|
||||
.Select(la => la.TypeOfOccupation!.ShortName),
|
||||
TypeOfOccupation = l.TypeOfOccupation!.ShortName,
|
||||
|
||||
Discipline = l.Discipline!.Name,
|
||||
DisciplineId = l.DisciplineId,
|
||||
|
||||
IsExcludedWeeks = l.IsExcludedWeeks,
|
||||
Weeks = l.SpecificWeeks?.Select(w => w.WeekNumber),
|
||||
|
||||
Group = l.Group!.Name,
|
||||
GroupId = l.GroupId,
|
||||
|
||||
@ -75,6 +68,7 @@ public class GetScheduleListQueryHandler(ILessonDbContext dbContext) : IRequestH
|
||||
.Where(la => la.LectureHall?.Campus != null)
|
||||
.Select(la => la.LectureHall?.CampusId),
|
||||
|
||||
|
||||
Professors = l.LessonAssociations!
|
||||
.Where(la => !string.IsNullOrEmpty(la.Professor?.Name))
|
||||
.Select(la => la.Professor?.Name),
|
||||
|
@ -34,14 +34,9 @@ public class ScheduleLookupDto
|
||||
public required int DisciplineId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets exclude or include weeks for a specific discipline.
|
||||
/// Gets or sets the type of occupation.
|
||||
/// </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; }
|
||||
public required string TypeOfOccupation { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the name of the group.
|
||||
@ -53,11 +48,6 @@ public class ScheduleLookupDto
|
||||
/// </summary>
|
||||
public required int GroupId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the type of occupation.
|
||||
/// </summary>
|
||||
public required IEnumerable<string> TypeOfOccupations { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the names of the lecture halls.
|
||||
/// </summary>
|
||||
|
@ -1,9 +0,0 @@
|
||||
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 DayOfWeek DayOfWeek { get; set; }
|
||||
public int PairNumber { get; set; }
|
||||
public bool? IsExcludedWeeks { get; set; }
|
||||
|
||||
public int GroupId { get; set; }
|
||||
public Group? Group { get; set; }
|
||||
public int TypeOfOccupationId { get; set; }
|
||||
public TypeOfOccupation? TypeOfOccupation { get; set; }
|
||||
public int DisciplineId { get; set; }
|
||||
public Discipline? Discipline { get; set; }
|
||||
|
||||
public List<LessonAssociation>? LessonAssociations { get; set; }
|
||||
public List<SpecificWeek>? SpecificWeeks { get; set; }
|
||||
}
|
@ -5,8 +5,6 @@ public class LessonAssociation
|
||||
public int Id { get; set; }
|
||||
public string? LinkToMeet { get; set; }
|
||||
|
||||
public int TypeOfOccupationId { get; set; }
|
||||
public TypeOfOccupation? TypeOfOccupation { get; set; }
|
||||
public int LessonId { get; set; }
|
||||
public Lesson? Lesson { get; set; }
|
||||
public int? ProfessorId { get; set; }
|
||||
|
@ -1,10 +0,0 @@
|
||||
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,6 +6,7 @@ public class TypeOfOccupation
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public required string ShortName { get; set; }
|
||||
public string? FullName { get; set; }
|
||||
|
||||
public List<LessonAssociation>? Lessons { get; set; }
|
||||
public List<Lesson>? Lessons { get; set; }
|
||||
}
|
@ -27,10 +27,10 @@ public class ScheduleController(IMediator mediator) : BaseControllerV1
|
||||
public async Task<ActionResult<List<ScheduleResponse>>> Get([FromBody] ScheduleRequest request)
|
||||
|
||||
{
|
||||
if ((request.Groups == null || request.Groups.Length == 0) &&
|
||||
(request.Disciplines == null || request.Disciplines.Length == 0) &&
|
||||
(request.Professors == null || request.Professors.Length == 0) &&
|
||||
(request.LectureHalls == null || request.LectureHalls.Length == 0))
|
||||
if ((request.Groups == null || !request.Groups.Any()) &&
|
||||
(request.Disciplines == null || !request.Disciplines.Any()) &&
|
||||
(request.Professors == null || !request.Professors.Any()) &&
|
||||
(request.LectureHalls == null || !request.LectureHalls.Any()))
|
||||
{
|
||||
return BadRequest(new ErrorResponse()
|
||||
{
|
||||
@ -60,9 +60,7 @@ public class ScheduleController(IMediator mediator) : BaseControllerV1
|
||||
IsEven = s.IsEven,
|
||||
Discipline = s.Discipline,
|
||||
DisciplineId = s.DisciplineId,
|
||||
IsExcludedWeeks = s.IsExcludedWeeks,
|
||||
Weeks = s.Weeks,
|
||||
TypeOfOccupations = s.TypeOfOccupations,
|
||||
TypeOfOccupation = s.TypeOfOccupation,
|
||||
Group = s.Group,
|
||||
GroupId = s.GroupId,
|
||||
LectureHalls = s.LectureHalls,
|
||||
@ -119,9 +117,7 @@ public class ScheduleController(IMediator mediator) : BaseControllerV1
|
||||
IsEven = g.IsEven,
|
||||
Discipline = g.Discipline,
|
||||
DisciplineId = g.DisciplineId,
|
||||
IsExcludedWeeks = g.IsExcludedWeeks,
|
||||
Weeks = g.Weeks,
|
||||
TypeOfOccupations = g.TypeOfOccupations,
|
||||
TypeOfOccupation = g.TypeOfOccupation,
|
||||
LectureHalls = g.LectureHalls,
|
||||
LectureHallsId = g.LectureHallsId,
|
||||
Professors = g.Professors,
|
||||
@ -180,9 +176,7 @@ public class ScheduleController(IMediator mediator) : BaseControllerV1
|
||||
IsEven = p.IsEven,
|
||||
Discipline = p.Discipline,
|
||||
DisciplineId = p.DisciplineId,
|
||||
IsExcludedWeeks = p.IsExcludedWeeks,
|
||||
Weeks = p.Weeks,
|
||||
TypeOfOccupations = p.TypeOfOccupations,
|
||||
TypeOfOccupation = p.TypeOfOccupation,
|
||||
Group = p.Group,
|
||||
GroupId = p.GroupId,
|
||||
LectureHalls = p.LectureHalls,
|
||||
@ -241,9 +235,7 @@ public class ScheduleController(IMediator mediator) : BaseControllerV1
|
||||
IsEven = l.IsEven,
|
||||
Discipline = l.Discipline,
|
||||
DisciplineId = l.DisciplineId,
|
||||
IsExcludedWeeks = l.IsExcludedWeeks,
|
||||
Weeks = l.Weeks,
|
||||
TypeOfOccupations = l.TypeOfOccupations,
|
||||
TypeOfOccupation = l.TypeOfOccupation,
|
||||
Group = l.Group,
|
||||
GroupId = l.GroupId,
|
||||
Professors = l.Professors,
|
||||
@ -281,7 +273,7 @@ public class ScheduleController(IMediator mediator) : BaseControllerV1
|
||||
IsEven = isEven,
|
||||
DisciplineIds = [id],
|
||||
GroupIds = groups,
|
||||
LectureHallIds = lectureHalls,
|
||||
LectureHallIds = [id],
|
||||
ProfessorIds = professors
|
||||
})).Schedules;
|
||||
|
||||
@ -296,7 +288,7 @@ public class ScheduleController(IMediator mediator) : BaseControllerV1
|
||||
DayOfWeek = d.DayOfWeek,
|
||||
PairNumber = d.PairNumber,
|
||||
IsEven = d.IsEven,
|
||||
TypeOfOccupation = d.TypeOfOccupations,
|
||||
TypeOfOccupation = d.TypeOfOccupation,
|
||||
Group = d.Group,
|
||||
GroupId = d.GroupId,
|
||||
LectureHalls = d.LectureHalls,
|
||||
|
@ -1,17 +0,0 @@
|
||||
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,7 +43,6 @@ public static class DependencyInjection
|
||||
services.AddDbContext<ProfessorDbContext>(dbConfig);
|
||||
services.AddDbContext<LessonDbContext>(dbConfig);
|
||||
services.AddDbContext<TypeOfOccupationDbContext>(dbConfig);
|
||||
services.AddDbContext<SpecificWeekDbContext>(dbConfig);
|
||||
|
||||
services.AddDbContext<UberDbContext>(dbConfig);
|
||||
}
|
||||
@ -59,7 +58,6 @@ public static class DependencyInjection
|
||||
services.AddScoped<IProfessorDbContext>(provider => provider.GetService<ProfessorDbContext>()!);
|
||||
services.AddScoped<ILessonDbContext>(provider => provider.GetService<LessonDbContext>()!);
|
||||
services.AddScoped<ITypeOfOccupationDbContext>(provider => provider.GetService<TypeOfOccupationDbContext>()!);
|
||||
services.AddScoped<ISpecificWeekDbContext>(provider => provider.GetService<SpecificWeekDbContext>()!);
|
||||
|
||||
return services;
|
||||
}
|
||||
|
@ -18,8 +18,6 @@ public class LessonAssociationConfiguration : IEntityTypeConfiguration<LessonAss
|
||||
builder.Property(l => l.LessonId).HasColumnType("INTEGER").IsRequired();
|
||||
builder.Property(l => l.ProfessorId).HasColumnType("INTEGER");
|
||||
builder.Property(l => l.LectureHallId).HasColumnType("INTEGER");
|
||||
builder.Property(l => l.TypeOfOccupationId).HasColumnType("INTEGER").IsRequired();
|
||||
|
||||
|
||||
builder
|
||||
.HasOne(l => l.Lesson)
|
||||
@ -38,11 +36,5 @@ public class LessonAssociationConfiguration : IEntityTypeConfiguration<LessonAss
|
||||
.WithMany(l => l.LessonAssociations)
|
||||
.HasForeignKey(l => l.LectureHallId)
|
||||
.OnDelete(DeleteBehavior.SetNull);
|
||||
|
||||
builder
|
||||
.HasOne(l => l.TypeOfOccupation)
|
||||
.WithMany(t => t.Lessons)
|
||||
.HasForeignKey(d => d.TypeOfOccupationId)
|
||||
.OnDelete(DeleteBehavior.Cascade);
|
||||
}
|
||||
}
|
@ -13,20 +13,27 @@ public class LessonConfiguration : IEntityTypeConfiguration<Lesson>
|
||||
builder.HasIndex(l => l.Id).IsUnique();
|
||||
builder.Property(l => l.Id).HasColumnType("INTEGER").IsRequired().ValueGeneratedOnAdd();
|
||||
|
||||
builder.Property(l => l.IsEven).HasColumnType("BOOLEAN").IsRequired();
|
||||
builder.Property(l => l.IsEven).HasColumnType("BIT").IsRequired();
|
||||
builder.Property(l => l.DayOfWeek).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.TypeOfOccupationId).HasColumnType("INTEGER").IsRequired();
|
||||
builder.Property(l => l.DisciplineId).HasColumnType("INTEGER").IsRequired();
|
||||
|
||||
|
||||
builder
|
||||
.HasOne(l => l.Group)
|
||||
.WithMany(g => g.Lessons)
|
||||
.HasForeignKey(d => d.GroupId)
|
||||
.OnDelete(DeleteBehavior.Cascade);
|
||||
|
||||
builder
|
||||
.HasOne(l => l.TypeOfOccupation)
|
||||
.WithMany(t => t.Lessons)
|
||||
.HasForeignKey(d => d.TypeOfOccupationId)
|
||||
.OnDelete(DeleteBehavior.Cascade);
|
||||
|
||||
builder
|
||||
.HasOne(l => l.Discipline)
|
||||
.WithMany(d => d.Lessons)
|
||||
|
@ -1,26 +0,0 @@
|
||||
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,5 +14,6 @@ public class TypeOfOccupationConfiguration : IEntityTypeConfiguration<TypeOfOccu
|
||||
builder.Property(t => t.Id).HasColumnType("INTEGER").IsRequired().ValueGeneratedOnAdd();
|
||||
|
||||
builder.Property(t => t.ShortName).HasColumnType("TEXT").IsRequired().HasMaxLength(16);
|
||||
builder.Property(t => t.FullName).HasColumnType("TEXT").HasMaxLength(64);
|
||||
}
|
||||
}
|
@ -15,7 +15,6 @@ public class UberDbContext(DbContextOptions<UberDbContext> options) : DbContext(
|
||||
public DbSet<Lesson> Lessons { get; set; } = null!;
|
||||
public DbSet<Professor> Professors { get; set; } = null!;
|
||||
public DbSet<TypeOfOccupation> TypeOfOccupations { get; set; } = null!;
|
||||
public DbSet<SpecificWeek> SpecificWeeks { get; set; } = null!;
|
||||
|
||||
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
||||
{
|
||||
@ -28,7 +27,6 @@ public class UberDbContext(DbContextOptions<UberDbContext> options) : DbContext(
|
||||
modelBuilder.ApplyConfiguration(new ProfessorConfiguration());
|
||||
modelBuilder.ApplyConfiguration(new LessonAssociationConfiguration());
|
||||
modelBuilder.ApplyConfiguration(new TypeOfOccupationConfiguration());
|
||||
modelBuilder.ApplyConfiguration(new SpecificWeekConfiguration());
|
||||
|
||||
base.OnModelCreating(modelBuilder);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user