using System; using System.Collections.Generic; using Volo.Abp.Domain.Entities.Auditing; namespace Kurs.Platform.Entities; public class Classroom : FullAuditedEntity { public string Name { get; set; } public string Description { get; set; } public string Subject { get; set; } public Guid? TeacherId { get; set; } public string TeacherName { get; set; } public DateTime ScheduledStartTime { get; set; } public DateTime? ActualStartTime { get; set; } public DateTime? EndTime { get; set; } public int Duration { get; set; } public int MaxParticipants { get; set; } public bool IsActive { get; set; } public bool IsScheduled { get; set; } public int ParticipantCount { get; set; } public string SettingsJson { get; set; } public virtual ICollection Participants { get; set; } public virtual ICollection AttendanceRecords { get; set; } public virtual ICollection ChatMessages { get; set; } protected Classroom() { Participants = new HashSet(); AttendanceRecords = new HashSet(); ChatMessages = new HashSet(); } public Classroom( Guid id, string name, string description, string subject, Guid? teacherId, string teacherName, DateTime scheduledStartTime, int duration, int maxParticipants, bool isActive, bool isScheduled, string settingsJson ) : base(id) { Name = name; Description = description; Subject = subject; TeacherId = teacherId; TeacherName = teacherName; ScheduledStartTime = scheduledStartTime; Duration = duration; MaxParticipants = maxParticipants; IsActive = isActive; IsScheduled = isScheduled; SettingsJson = settingsJson; Participants = new HashSet(); AttendanceRecords = new HashSet(); ChatMessages = new HashSet(); } public bool CanJoin() { var now = DateTime.Now; var tenMinutesBefore = ScheduledStartTime.AddMinutes(-10); var twoHoursAfter = ScheduledStartTime.AddHours(2); return now >= tenMinutesBefore && now <= twoHoursAfter && ParticipantCount < MaxParticipants; } }