erp-platform/api/src/Kurs.Platform.Domain/Classroom/Classroom.cs

76 lines
2.4 KiB
C#
Raw Normal View History

2025-08-25 18:01:57 +00:00
using System;
using System.Collections.Generic;
using Volo.Abp.Domain.Entities.Auditing;
namespace Kurs.Platform.Entities;
2025-08-26 05:59:39 +00:00
public class Classroom : FullAuditedEntity<Guid>
2025-08-25 18:01:57 +00:00
{
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; }
2025-08-25 18:01:57 +00:00
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; }
2025-08-25 18:01:57 +00:00
2025-08-26 05:59:39 +00:00
public virtual ICollection<ClassParticipant> Participants { get; set; }
public virtual ICollection<ClassAttandance> AttendanceRecords { get; set; }
public virtual ICollection<ClassChat> ChatMessages { get; set; }
2025-08-25 18:01:57 +00:00
2025-08-26 05:59:39 +00:00
protected Classroom()
2025-08-25 18:01:57 +00:00
{
2025-08-26 05:59:39 +00:00
Participants = new HashSet<ClassParticipant>();
AttendanceRecords = new HashSet<ClassAttandance>();
ChatMessages = new HashSet<ClassChat>();
2025-08-25 18:01:57 +00:00
}
2025-08-26 05:59:39 +00:00
public Classroom(
2025-08-25 18:01:57 +00:00
Guid id,
string name,
string description,
string subject,
Guid? teacherId,
string teacherName,
DateTime scheduledStartTime,
int duration,
int maxParticipants,
bool isActive,
bool isScheduled,
string settingsJson
2025-08-25 18:01:57 +00:00
) : base(id)
{
Name = name;
Description = description;
Subject = subject;
TeacherId = teacherId;
TeacherName = teacherName;
ScheduledStartTime = scheduledStartTime;
Duration = duration;
MaxParticipants = maxParticipants;
IsActive = isActive;
IsScheduled = isScheduled;
SettingsJson = settingsJson;
2025-08-25 18:01:57 +00:00
2025-08-26 05:59:39 +00:00
Participants = new HashSet<ClassParticipant>();
AttendanceRecords = new HashSet<ClassAttandance>();
ChatMessages = new HashSet<ClassChat>();
2025-08-25 18:01:57 +00:00
}
public bool CanJoin()
{
2025-08-27 15:00:22 +00:00
var now = DateTime.Now;
2025-08-25 18:01:57 +00:00
var tenMinutesBefore = ScheduledStartTime.AddMinutes(-10);
var twoHoursAfter = ScheduledStartTime.AddHours(2);
return now >= tenMinutesBefore && now <= twoHoursAfter && ParticipantCount < MaxParticipants;
}
}