ddb743847d
This commit introduces several new services and models to manage the meeting schedule state within localStorage. The MeetingScheduleState class is created to track scheduled teams, absent students, time slot counts, extended teams, and excluded students. Additionally, the IMeetingScheduleStateService interface and its implementation, MeetingScheduleStateService, are added to handle loading and saving state data. The MeetingScheduleClipboardService and MeetingScheduleDataService are also introduced to facilitate clipboard operations and data loading from the database, respectively. These enhancements improve the overall functionality and user experience of the meeting scheduling feature.
49 lines
1.8 KiB
C#
49 lines
1.8 KiB
C#
using Core.Entities;
|
|
|
|
namespace Core.Models;
|
|
|
|
public class PartialTeam : Team
|
|
{
|
|
public IList<Student> OmittedStudents { get; set; } = null!;
|
|
|
|
public override Team CloneWithOmittedStudents(IEnumerable<Student> studentsToOmit)
|
|
{
|
|
var remainingStudents = Students.Where(s => !studentsToOmit.Contains(s)).ToList();
|
|
var omittedStudents = OmittedStudents.Union(Students.Where(studentsToOmit.Contains)).Distinct().ToList();
|
|
return new PartialTeam{Identifier = Identifier, Event = Event, Students = remainingStudents, OmittedStudents = omittedStudents };
|
|
}
|
|
|
|
/// <summary>
|
|
/// Creates PartialTeam instances from teams with excluded students.
|
|
/// Aggregates exclusions across all time slots for each team.
|
|
/// </summary>
|
|
/// <param name="teams">The teams to process</param>
|
|
/// <param name="excludedStudents">Dictionary of excluded students: key is (teamId, timeSlotIndex, studentId), value is true if excluded</param>
|
|
/// <returns>Array of teams, with PartialTeam instances for teams with exclusions</returns>
|
|
public static Team[] CreatePartialTeamsFromExclusions(
|
|
IEnumerable<Team> teams,
|
|
Dictionary<(int teamId, int timeSlotIndex, int studentId), bool> excludedStudents)
|
|
{
|
|
return teams.Select(team =>
|
|
{
|
|
// Find all students excluded for this team across all time slots
|
|
var excludedStudentIds = excludedStudents.Keys
|
|
.Where(k => k.teamId == team.Id && excludedStudents[k])
|
|
.Select(k => k.studentId)
|
|
.Distinct()
|
|
.ToHashSet();
|
|
|
|
if (excludedStudentIds.Count == 0)
|
|
return team;
|
|
|
|
var excludedStudentsList = team.Students.Where(s => excludedStudentIds.Contains(s.Id)).ToList();
|
|
if (excludedStudentsList.Count == 0)
|
|
return team;
|
|
|
|
// Create PartialTeam with excluded students
|
|
return team.CloneWithOmittedStudents(excludedStudentsList);
|
|
}).ToArray();
|
|
}
|
|
}
|
|
|