Compare commits

..
14 Commits
Author SHA1 Message Date
poprhythm 680f61241a Refactor Calendar component to simplify view selection UI
This commit removes the Month and Day button group from the Calendar component, streamlining the user interface. The change enhances the overall layout and focuses on the MudCalendar display, improving user experience by reducing visual clutter. This update aligns with the ongoing efforts to refine component interactions and maintain a clean UI.
2026-01-25 21:59:43 -05:00
poprhythm 083e81aa25 Refactor PageNoteButton component to include popover for note content display
This commit enhances the PageNoteButton component by wrapping the MudButton in a div that manages mouse events to control the visibility of a MudPopover. The popover displays detailed note content when the button is hovered over, improving user interaction and accessibility of page notes. Additionally, the component's state management is updated to handle the new popover functionality, ensuring a seamless user experience.
2026-01-25 21:59:31 -05:00
poprhythm bba0f5f618 Fix formatting issue in Team entity and improve ToString method for null safety
This commit addresses a formatting issue in the Team.cs file by removing an invisible character at the beginning of the file. Additionally, the ToString method is updated to safely handle null values for the Event property, ensuring that it returns a default message when no event is associated with the team. These changes enhance code readability and prevent potential null reference exceptions.
2026-01-25 21:59:16 -05:00
poprhythm 9ab241ed77 Update MeetingSchedule and related components for improved UI and data handling
This commit modifies the MeetingSchedule component to change the page header title to "Meeting Scheduler Planner" for better clarity. Additionally, it refines the MeetingHistoryDetailDialog by removing unnecessary UI elements to streamline the display of meeting history details. In the Printout component, null checks are added to ensure safe access to LevelOfEffort properties, enhancing data integrity. The Home component's title is also updated to "Meeting Schedule Planner" for consistency across the application. These changes collectively enhance the user experience and maintain data accuracy in the meeting scheduling feature.
2026-01-25 21:40:04 -05:00
poprhythm 804e12ca22 Refactor History component in MeetingSchedule to enhance table structure and styling
This commit updates the History component by replacing the MudTable with a custom HTML table structure for improved styling and responsiveness. The table now features enhanced column definitions, including vertical text orientation for headers and improved row styling for better readability. Additionally, CSS styles are introduced to manage table appearance, ensuring a more user-friendly interface for displaying meeting histories. This enhancement contributes to a better overall user experience in the meeting schedule feature.
2026-01-25 21:16:26 -05:00
poprhythm cc6e0d71a7 Integrate TeamMeetingHistoryService into Calendar component for enhanced meeting management
This commit updates the Calendar component to include the ITeamMeetingHistoryService, allowing for the loading and display of meeting histories alongside event occurrences. The calendar items are now wrapped in CalendarItemWrapper to accommodate both events and meetings. Additionally, error handling and logging are implemented to ensure robustness during the loading process. This enhancement improves the overall functionality and user experience of the calendar feature by providing a comprehensive view of both events and meetings.
2026-01-25 19:07:43 -05:00
poprhythm a503655f97 Enhance MeetingSchedule and MeetingHistoryDetailDialog with load into planner functionality
This commit adds a new feature to the MeetingSchedule and MeetingHistoryDetailDialog components, allowing users to load meeting details into the planner. The LoadMeetingIntoPlanner method is implemented in both components, which retrieves team and student data, calculates absent students, and saves the state to localStorage before navigating to the planner. Additionally, a confirmation dialog is introduced in the SaveMeetingHistoryDialog to handle overwriting existing meeting histories, improving user experience and data management in the meeting scheduling feature.
2026-01-25 18:58:02 -05:00
poprhythm 6e2834f2be Refactor MeetingSchedule component to enhance time slot selection UI
This commit updates the MeetingSchedule component by replacing the numeric field for time slot selection with a more user-friendly interface using MudIconButton components for incrementing and decrementing time slots. The new design improves usability by providing clear visual controls for adjusting the number of time slots, while maintaining the existing functionality of tracking time slot counts. This enhancement contributes to a better user experience in managing meeting schedules.
2026-01-21 21:36:39 -05:00
poprhythm 48861eb6a6 Add TeamClipboardMatcher utility and corresponding tests for fuzzy team name matching
This commit introduces the TeamClipboardMatcher class, which provides functionality to match team names from clipboard text using fuzzy matching techniques. The class includes methods for extracting team names and finding the best match based on a specified threshold. Additionally, comprehensive unit tests are added in TeamClipboardMatcher_Tests to validate various matching scenarios, including exact matches, fuzzy matches, and handling of different clipboard formats. This enhancement improves the application's ability to efficiently match teams from user input.
2026-01-20 22:49:09 -05:00
poprhythm 455be30821 Enhance MeetingHistoryDetailDialog and SaveMeetingHistoryDialog with navigation and editing features
This commit introduces navigation buttons for previous and next meeting histories in the MeetingHistoryDetailDialog, improving user experience by allowing easy access to related meetings. Additionally, the SaveMeetingHistoryDialog is updated to support editing existing meeting histories, with logic to load existing data and prevent duplicate entries for the same date. The integration of TeamToggleSelector and StudentToggleSelector components streamlines team and student selection, enhancing the overall functionality of the meeting history management feature.
2026-01-20 21:55:38 -05:00
poprhythm ddb743847d Add meeting schedule state management services and related models
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.
2026-01-19 23:02:55 -05:00
poprhythm 649a0061cf Enhance team overlap calculation by excluding absent students
This commit updates the GetTeamsWithoutExcludedStudents method to filter out both excluded and absent students during overlap calculations. A new HashSet is introduced to store absent student IDs, improving the accuracy of team compositions. This change ensures that the team formation logic accounts for student availability, enhancing the overall functionality of the meeting schedule feature.
2026-01-19 22:42:44 -05:00
poprhythm 6bc4c2e7f2 Add TeamMeetingHistory entity, service, and UI components for meeting history management
This commit introduces the TeamMeetingHistory entity, including its configuration and database migrations. A new ITeamMeetingHistoryService interface and its implementation, TeamMeetingHistoryService, are added to handle CRUD operations for meeting histories. Additionally, UI components such as History.razor, MeetingHistoryDetailDialog, and SaveMeetingHistoryDialog are created to facilitate viewing and saving meeting histories. The integration of INoteNamingService enhances note management for meeting records, improving overall functionality and user experience in the application.
2026-01-19 22:02:59 -05:00
poprhythm 9ed9c93540 Refactor InteractiveChip component to improve touch event handling
This commit updates the InteractiveChip component by refining touch event handling for better user interaction on touch devices. The `HandleClick` method has been replaced with `HandleTouchStart`, which now toggles the `_isTouched` state and prevents event propagation. This change enhances the responsiveness of the component, ensuring a smoother experience for users on mobile devices while maintaining existing hover functionality for desktop users.
2026-01-19 12:09:57 -05:00
42 changed files with 4137 additions and 543 deletions
@@ -0,0 +1,58 @@
using Core.Entities;
namespace Core.Calculation;
/// <summary>
/// Helper methods for calculating overlaps in team scheduling solutions.
/// </summary>
public static class OverlapCalculationHelper
{
/// <summary>
/// Creates teams with excluded students and absent students filtered out for overlap calculation.
/// </summary>
/// <param name="teams">The teams to filter</param>
/// <param name="timeSlotIndex">The time slot index for exclusion lookups</param>
/// <param name="excludedStudents">Dictionary of excluded students: key is (teamId, timeSlotIndex, studentId), value is true if excluded</param>
/// <param name="absentStudentIds">Set of absent student IDs to exclude from overlap calculations</param>
/// <returns>Teams with excluded and absent students removed</returns>
public static Team[] GetTeamsWithoutExcludedStudents(
Team[] teams,
int timeSlotIndex,
Dictionary<(int teamId, int timeSlotIndex, int studentId), bool> excludedStudents,
HashSet<int> absentStudentIds)
{
return teams.Select(team =>
{
// Find excluded students for this team in this time slot
// Also exclude absent students from overlap calculations
var includedStudents = team.Students
.Where(s => !IsStudentExcluded(team.Id, timeSlotIndex, s.Id, excludedStudents) &&
!absentStudentIds.Contains(s.Id))
.ToList();
// If no students are excluded, return original team
if (includedStudents.Count == team.Students.Count)
return team;
// Create a temporary team with excluded and absent students removed
return new Team
{
Id = team.Id,
Event = team.Event,
Students = includedStudents,
Captain = team.Captain,
Identifier = team.Identifier
};
}).ToArray();
}
private static bool IsStudentExcluded(
int teamId,
int timeSlotIndex,
int studentId,
Dictionary<(int teamId, int timeSlotIndex, int studentId), bool> excludedStudents)
{
var key = (teamId, timeSlotIndex, studentId);
return excludedStudents.TryGetValue(key, out var isExcluded) && isExcluded;
}
}
@@ -0,0 +1,89 @@
using Core.Entities;
namespace Core.Calculation;
/// <summary>
/// Post-processing utilities for team scheduler solutions.
/// </summary>
public static class TeamSchedulerPostProcessor
{
/// <summary>
/// Extends teams to adjacent time slots (both forward and backward).
/// Teams marked as extended will appear in consecutive time slots.
/// </summary>
/// <param name="solution">The scheduler solution to modify</param>
/// <param name="extendedTeams">Teams that should be extended to adjacent slots</param>
/// <param name="allStudents">All available students for overlap calculations</param>
/// <param name="getTeamsWithoutExcludedStudents">Function to filter teams for overlap calculation</param>
public static void ExtendTeamsInSolution(
TeamSchedulerSolution solution,
IEnumerable<Team> extendedTeams,
Student[] allStudents,
Func<Team[], int, Team[]> getTeamsWithoutExcludedStudents)
{
if (solution.TimeSlots == null || !solution.TimeSlots.Any())
return;
var extendedTeamsList = extendedTeams.ToList();
if (!extendedTeamsList.Any())
return;
var extendedTeamIds = extendedTeamsList.Select(t => t.Id).ToHashSet();
// Find which time slot each extended team is in and extend both forward and backward
for (int slotIndex = 0; slotIndex < solution.TimeSlots.Length; slotIndex++)
{
var currentSlot = solution.TimeSlots[slotIndex];
var teamsToExtend = currentSlot.Teams.Where(t => extendedTeamIds.Contains(t.Id)).ToList();
if (!teamsToExtend.Any())
continue;
// Extend forward: add to next time slot (if exists)
if (slotIndex + 1 < solution.TimeSlots.Length)
{
var nextSlot = solution.TimeSlots[slotIndex + 1];
var nextSlotTeamsList = nextSlot.Teams.ToList();
var nextSlotTeamIds = nextSlotTeamsList.Select(t => t.Id).ToHashSet();
foreach (var team in teamsToExtend)
{
if (!nextSlotTeamIds.Contains(team.Id))
{
nextSlotTeamsList.Add(team);
nextSlotTeamIds.Add(team.Id);
}
}
nextSlot.Teams = nextSlotTeamsList.ToArray();
var nextSlotIndex = slotIndex + 1;
var nextSlotTeamsForOverlap = getTeamsWithoutExcludedStudents(nextSlot.Teams, nextSlotIndex);
nextSlot.StudentOverlaps = TeamSchedulerSolution.GetStudentTeamOverlaps(nextSlotTeamsForOverlap);
nextSlot.UnscheduledStudents = TeamSchedulerSolution.GetStudentsNotInTimSlot(nextSlotTeamsForOverlap, allStudents);
}
// Extend backward: add to previous time slot (if exists)
if (slotIndex > 0)
{
var previousSlot = solution.TimeSlots[slotIndex - 1];
var previousSlotTeamsList = previousSlot.Teams.ToList();
var previousSlotTeamIds = previousSlotTeamsList.Select(t => t.Id).ToHashSet();
foreach (var team in teamsToExtend)
{
if (!previousSlotTeamIds.Contains(team.Id))
{
previousSlotTeamsList.Add(team);
previousSlotTeamIds.Add(team.Id);
}
}
previousSlot.Teams = previousSlotTeamsList.ToArray();
var previousSlotIndex = slotIndex - 1;
var previousSlotTeamsForOverlap = getTeamsWithoutExcludedStudents(previousSlot.Teams, previousSlotIndex);
previousSlot.StudentOverlaps = TeamSchedulerSolution.GetStudentTeamOverlaps(previousSlotTeamsForOverlap);
previousSlot.UnscheduledStudents = TeamSchedulerSolution.GetStudentsNotInTimSlot(previousSlotTeamsForOverlap, allStudents);
}
}
}
}
+2 -2
View File
@@ -1,4 +1,4 @@
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations;
using Core.Models;
namespace Core.Entities;
@@ -61,6 +61,6 @@ public class Team
public override string ToString()
{
return $"{Event.Name} {(Identifier != null ? $"({Identifier})" : "")}";
return $"{Event?.Name ?? "(no event)"} {(Identifier != null ? $"({Identifier})" : "")}";
}
}
+16
View File
@@ -0,0 +1,16 @@
using System.ComponentModel.DataAnnotations;
namespace Core.Entities;
public class TeamMeetingHistory
{
public int Id { get; set; }
[Required]
[Display(Name = "Meeting Date")]
public DateTime MeetingDate { get; set; }
// Navigation properties
public List<Team> Teams { get; set; } = [];
public List<Student> Students { get; set; } = [];
}
+32
View File
@@ -12,5 +12,37 @@ public class PartialTeam : Team
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();
}
}
+38
View File
@@ -0,0 +1,38 @@
namespace Core.Services;
/// <summary>
/// Service for managing note naming conventions throughout the system.
/// Centralizes the logic for generating note titles for meeting notes and page notes.
/// </summary>
public interface INoteNamingService
{
/// <summary>
/// Gets the title for a meeting note based on the meeting date.
/// Format: "#Meeting Notes MM/dd/yyyy"
/// </summary>
/// <param name="meetingDate">The date of the meeting</param>
/// <returns>The formatted meeting note title</returns>
string GetMeetingNoteTitle(DateTime meetingDate);
/// <summary>
/// Gets the title for a page note based on the page identifier.
/// Format: "#{pageIdentifier}"
/// </summary>
/// <param name="pageIdentifier">The page identifier (e.g., "students", "teams")</param>
/// <returns>The formatted page note title</returns>
string GetPageNoteTitle(string pageIdentifier);
/// <summary>
/// Checks if a note title represents a page note (starts with "#").
/// </summary>
/// <param name="noteTitle">The note title to check</param>
/// <returns>True if the note is a page note, false otherwise</returns>
bool IsPageNote(string noteTitle);
/// <summary>
/// Checks if a note title represents a meeting note (starts with "#Meeting Notes").
/// </summary>
/// <param name="noteTitle">The note title to check</param>
/// <returns>True if the note is a meeting note, false otherwise</returns>
bool IsMeetingNote(string noteTitle);
}
+50
View File
@@ -0,0 +1,50 @@
namespace Core.Services;
/// <summary>
/// Implementation of INoteNamingService that provides note naming conventions.
/// Uses "#" as the prefix for page notes and meeting notes.
/// </summary>
public class NoteNamingService : INoteNamingService
{
private const string PageNotePrefix = "#";
private const string MeetingNotePrefix = "#Meeting Notes";
/// <inheritdoc/>
public string GetMeetingNoteTitle(DateTime meetingDate)
{
return $"{MeetingNotePrefix} {meetingDate:MM/dd/yyyy}";
}
/// <inheritdoc/>
public string GetPageNoteTitle(string pageIdentifier)
{
if (string.IsNullOrWhiteSpace(pageIdentifier))
{
throw new ArgumentException("Page identifier cannot be null or empty", nameof(pageIdentifier));
}
return $"{PageNotePrefix}{pageIdentifier}";
}
/// <inheritdoc/>
public bool IsPageNote(string noteTitle)
{
if (string.IsNullOrWhiteSpace(noteTitle))
{
return false;
}
return noteTitle.StartsWith(PageNotePrefix, StringComparison.Ordinal);
}
/// <inheritdoc/>
public bool IsMeetingNote(string noteTitle)
{
if (string.IsNullOrWhiteSpace(noteTitle))
{
return false;
}
return noteTitle.StartsWith(MeetingNotePrefix, StringComparison.Ordinal);
}
}
+91
View File
@@ -0,0 +1,91 @@
using Core.Entities;
using FuzzySharp;
namespace Core.Utility;
/// <summary>
/// Utility class for matching team names from clipboard text using fuzzy matching.
/// </summary>
public static class TeamClipboardMatcher
{
/// <summary>
/// Matches team names from clipboard text against available teams using fuzzy matching.
/// </summary>
/// <param name="clipboardText">The text content from the clipboard.</param>
/// <param name="availableTeams">The collection of available teams to match against.</param>
/// <param name="matchThreshold">The minimum fuzzy match score threshold (0-100). Default is 85.</param>
/// <returns>A list of teams that match the clipboard text, ordered by match quality.</returns>
public static List<Team> MatchTeamsFromClipboard(
string clipboardText,
IEnumerable<Team> availableTeams,
int matchThreshold = 85)
{
var matchedTeams = new List<Team>();
var teamsList = availableTeams.ToList();
if (string.IsNullOrWhiteSpace(clipboardText) || !teamsList.Any())
{
return matchedTeams;
}
// Split clipboard text by newlines
var lines = clipboardText.Split(new[] { "\r\n", "\r", "\n" }, StringSplitOptions.RemoveEmptyEntries);
foreach (var line in lines)
{
// Extract team name portion (before " - " if present, as clipboard format includes student lists)
var teamName = ExtractTeamNameFromLine(line);
// Skip empty lines or lines that look like headers/metadata
if (ShouldSkipLine(teamName))
{
continue;
}
// Find best match using fuzzy matching
var matchedTeam = FindBestMatch(teamName, teamsList, matchThreshold);
if (matchedTeam != null && !matchedTeams.Any(t => t.Id == matchedTeam.Id))
{
matchedTeams.Add(matchedTeam);
}
}
return matchedTeams;
}
private static string ExtractTeamNameFromLine(string line)
{
var dashIndex = line.IndexOf(" - ");
if (dashIndex > 0)
{
return line.Substring(0, dashIndex).Trim();
}
return line.Trim();
}
private static bool ShouldSkipLine(string teamName)
{
return string.IsNullOrWhiteSpace(teamName) ||
teamName.StartsWith("--") ||
teamName.Equals("Unscheduled", StringComparison.OrdinalIgnoreCase);
}
private static Team? FindBestMatch(string teamName, List<Team> availableTeams, int matchThreshold)
{
// Normalize both strings to lowercase for case-insensitive comparison
var normalizedTeamName = teamName.ToLowerInvariant();
var bestMatch = availableTeams
.Select(team => new
{
Team = team,
Score = Fuzz.Ratio(normalizedTeamName, team.ToString().ToLowerInvariant())
})
.Where(x => x.Score >= matchThreshold)
.OrderByDescending(x => x.Score)
.FirstOrDefault();
return bestMatch?.Team;
}
}
+50
View File
@@ -0,0 +1,50 @@
using Core.Entities;
namespace Core.Utility;
/// <summary>
/// Extension methods for filtering teams based on various criteria.
/// </summary>
public static class TeamFilterExtensions
{
/// <summary>
/// Adds teams that are regional events to the collection.
/// </summary>
public static IEnumerable<Team> AddRegionals(this IEnumerable<Team> currentTeams, IEnumerable<Team> allTeams)
{
return allTeams.Where(e => e.Event.RegionalEvent).Concat(currentTeams).Distinct();
}
/// <summary>
/// Adds teams with high level of effort (>= 3) to the collection.
/// </summary>
public static IEnumerable<Team> AddHighLevelOfEffort(this IEnumerable<Team> currentTeams, IEnumerable<Team> allTeams)
{
return allTeams.Where(e => e.Event.LevelOfEffort >= 3).Concat(currentTeams).Distinct();
}
/// <summary>
/// Removes individual event teams from the collection.
/// </summary>
public static IEnumerable<Team> RemoveIndividual(this IEnumerable<Team> teams)
{
return teams.Where(t => t.Event.EventFormat != EventFormat.Individual);
}
/// <summary>
/// Removes teams with low level of effort (<= 1) from the collection.
/// </summary>
public static IEnumerable<Team> RemoveLowLevelOfEffort(this IEnumerable<Team> teams)
{
return teams.Where(t => t.Event.LevelOfEffort > 1);
}
/// <summary>
/// Inverts the selection - returns all teams not in the current selection.
/// </summary>
public static IEnumerable<Team> Invert(this IEnumerable<Team> currentTeams, IEnumerable<Team> allTeams)
{
var currentTeamIds = currentTeams.Select(t => t.Id).ToHashSet();
return allTeams.Where(t => !currentTeamIds.Contains(t.Id));
}
}
+1
View File
@@ -14,6 +14,7 @@ namespace Data
public DbSet<Career> Careers { get; set; }
public DbSet<Note> Notes { get; set; }
public DbSet<NoteHistory> NoteHistories { get; set; }
public DbSet<TeamMeetingHistory> TeamMeetingHistories { get; set; }
public AppDbContext()
{
@@ -0,0 +1,29 @@
using Core.Entities;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
namespace Data.Configurations
{
public class TeamMeetingHistoryConfiguration : IEntityTypeConfiguration<TeamMeetingHistory>
{
public void Configure(EntityTypeBuilder<TeamMeetingHistory> builder)
{
builder.HasKey(tmh => tmh.Id);
// Indexes
builder.HasIndex(tmh => tmh.MeetingDate);
// Constraints
builder.Property(tmh => tmh.MeetingDate)
.IsRequired();
builder.HasMany(tmh => tmh.Teams)
.WithMany()
.UsingEntity(j => j.ToTable("TeamMeetingHistoryTeams"));
builder.HasMany(tmh => tmh.Students)
.WithMany()
.UsingEntity(j => j.ToTable("TeamMeetingHistoryStudents"));
}
}
}
@@ -0,0 +1,567 @@
// <auto-generated />
using System;
using Data;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
#nullable disable
namespace Data.Migrations
{
[DbContext(typeof(AppDbContext))]
[Migration("20260120024048_AddTeamMeetingHistory")]
partial class AddTeamMeetingHistory
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder.HasAnnotation("ProductVersion", "9.0.8");
modelBuilder.Entity("CareerEventDefinition", b =>
{
b.Property<int>("EventDefinitionId")
.HasColumnType("INTEGER");
b.Property<int>("RelatedCareersId")
.HasColumnType("INTEGER");
b.HasKey("EventDefinitionId", "RelatedCareersId");
b.HasIndex("RelatedCareersId");
b.ToTable("EventDefinitionCareers", (string)null);
});
modelBuilder.Entity("Core.Entities.Career", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<string>("Name")
.IsRequired()
.HasMaxLength(200)
.HasColumnType("TEXT");
b.HasKey("Id");
b.HasIndex("Name")
.IsUnique();
b.ToTable("Careers");
});
modelBuilder.Entity("Core.Entities.EventDefinition", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<int>("ChapterEligibilityCountRegionals")
.HasColumnType("INTEGER");
b.Property<int>("ChapterEligibilityCountState")
.HasColumnType("INTEGER");
b.Property<string>("Description")
.HasMaxLength(1000)
.HasColumnType("TEXT");
b.Property<string>("Documentation")
.HasMaxLength(500)
.HasColumnType("TEXT");
b.Property<string>("Eligibility")
.IsRequired()
.HasMaxLength(200)
.HasColumnType("TEXT");
b.Property<string>("EventFormat")
.IsRequired()
.HasMaxLength(50)
.HasColumnType("TEXT");
b.Property<int?>("LevelOfEffort")
.HasColumnType("INTEGER");
b.Property<int>("MaxTeamSize")
.HasColumnType("INTEGER");
b.Property<int>("MinTeamSize")
.HasColumnType("INTEGER");
b.Property<string>("Name")
.IsRequired()
.HasMaxLength(128)
.HasColumnType("TEXT");
b.Property<string>("Notes")
.HasMaxLength(1024)
.HasColumnType("TEXT");
b.Property<bool>("OnSiteActivity")
.HasColumnType("INTEGER");
b.Property<bool>("Presubmission")
.HasColumnType("INTEGER");
b.Property<string>("SemifinalistActivity")
.HasMaxLength(500)
.HasColumnType("TEXT");
b.Property<string>("ShortName")
.IsRequired()
.HasMaxLength(50)
.HasColumnType("TEXT");
b.Property<string>("Theme")
.HasMaxLength(500)
.HasColumnType("TEXT");
b.HasKey("Id");
b.HasIndex("EventFormat");
b.HasIndex("Name")
.IsUnique();
b.ToTable("Events");
});
modelBuilder.Entity("Core.Entities.EventOccurrence", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<string>("Date")
.IsRequired()
.HasMaxLength(100)
.HasColumnType("TEXT");
b.Property<DateTime?>("EndTime")
.HasColumnType("TEXT");
b.Property<int?>("EventDefinitionId")
.HasColumnType("INTEGER");
b.Property<string>("Location")
.HasMaxLength(500)
.HasColumnType("TEXT");
b.Property<string>("Name")
.IsRequired()
.HasMaxLength(200)
.HasColumnType("TEXT");
b.Property<string>("SpecialEventType")
.HasMaxLength(50)
.HasColumnType("TEXT");
b.Property<DateTime>("StartTime")
.HasColumnType("TEXT");
b.Property<string>("Time")
.IsRequired()
.HasMaxLength(100)
.HasColumnType("TEXT");
b.HasKey("Id");
b.HasIndex("EventDefinitionId");
b.HasIndex("SpecialEventType");
b.HasIndex("StartTime");
b.ToTable("EventOccurrences");
});
modelBuilder.Entity("Core.Entities.Note", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<string>("Content")
.HasColumnType("TEXT");
b.Property<DateTime>("CreatedAt")
.HasColumnType("TEXT");
b.Property<string>("CreatedBy")
.HasMaxLength(255)
.HasColumnType("TEXT");
b.Property<bool>("IsDeleted")
.HasColumnType("INTEGER");
b.Property<bool>("IsPinned")
.HasColumnType("INTEGER");
b.Property<string>("LastModifiedBy")
.HasMaxLength(255)
.HasColumnType("TEXT");
b.Property<string>("Title")
.IsRequired()
.HasMaxLength(200)
.HasColumnType("TEXT");
b.Property<DateTime>("UpdatedAt")
.HasColumnType("TEXT");
b.HasKey("Id");
b.HasIndex("CreatedAt");
b.HasIndex("IsDeleted");
b.HasIndex("IsPinned");
b.HasIndex("Title");
b.ToTable("Notes");
});
modelBuilder.Entity("Core.Entities.NoteHistory", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<string>("ChangeType")
.IsRequired()
.HasMaxLength(50)
.HasColumnType("TEXT");
b.Property<string>("Content")
.HasColumnType("TEXT");
b.Property<DateTime>("ModifiedAt")
.HasColumnType("TEXT");
b.Property<string>("ModifiedBy")
.HasMaxLength(255)
.HasColumnType("TEXT");
b.Property<int>("NoteId")
.HasColumnType("INTEGER");
b.Property<string>("Title")
.IsRequired()
.HasMaxLength(200)
.HasColumnType("TEXT");
b.HasKey("Id");
b.HasIndex("ModifiedAt");
b.HasIndex("NoteId");
b.HasIndex("NoteId", "ModifiedAt");
b.ToTable("NoteHistories");
});
modelBuilder.Entity("Core.Entities.Student", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<string>("Email")
.HasMaxLength(255)
.HasColumnType("TEXT");
b.Property<string>("FirstName")
.IsRequired()
.HasMaxLength(100)
.HasColumnType("TEXT");
b.Property<int>("Grade")
.HasColumnType("INTEGER");
b.Property<string>("LastName")
.IsRequired()
.HasMaxLength(100)
.HasColumnType("TEXT");
b.Property<string>("NationalId")
.HasMaxLength(50)
.HasColumnType("TEXT");
b.Property<string>("OfficerRole")
.HasMaxLength(50)
.HasColumnType("TEXT");
b.Property<string>("PhoneNumber")
.HasMaxLength(20)
.HasColumnType("TEXT");
b.Property<string>("RegionalId")
.HasMaxLength(50)
.HasColumnType("TEXT");
b.Property<string>("StateId")
.HasMaxLength(50)
.HasColumnType("TEXT");
b.Property<int>("TsaYear")
.HasColumnType("INTEGER");
b.HasKey("Id");
b.HasIndex("Email");
b.HasIndex("Grade");
b.HasIndex("FirstName", "LastName");
b.ToTable("Students");
});
modelBuilder.Entity("Core.Entities.StudentEventRanking", b =>
{
b.Property<int>("StudentId")
.HasColumnType("INTEGER");
b.Property<int>("EventDefinitionId")
.HasColumnType("INTEGER");
b.Property<int>("Rank")
.HasColumnType("INTEGER");
b.HasKey("StudentId", "EventDefinitionId");
b.HasIndex("EventDefinitionId");
b.HasIndex("Rank");
b.HasIndex("StudentId");
b.ToTable("StudentEventRanking");
});
modelBuilder.Entity("Core.Entities.Team", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<int?>("CaptainId")
.HasColumnType("INTEGER");
b.Property<int>("EventId")
.HasColumnType("INTEGER");
b.Property<string>("Identifier")
.HasMaxLength(50)
.HasColumnType("TEXT");
b.HasKey("Id");
b.HasIndex("CaptainId");
b.HasIndex("EventId");
b.HasIndex("EventId", "Identifier");
b.ToTable("Teams");
});
modelBuilder.Entity("Core.Entities.TeamMeetingHistory", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<DateTime>("MeetingDate")
.HasColumnType("TEXT");
b.HasKey("Id");
b.HasIndex("MeetingDate");
b.ToTable("TeamMeetingHistories");
});
modelBuilder.Entity("StudentTeam", b =>
{
b.Property<int>("StudentsId")
.HasColumnType("INTEGER");
b.Property<int>("TeamsId")
.HasColumnType("INTEGER");
b.HasKey("StudentsId", "TeamsId");
b.HasIndex("TeamsId");
b.ToTable("TeamStudents", (string)null);
});
modelBuilder.Entity("StudentTeamMeetingHistory", b =>
{
b.Property<int>("StudentsId")
.HasColumnType("INTEGER");
b.Property<int>("TeamMeetingHistoryId")
.HasColumnType("INTEGER");
b.HasKey("StudentsId", "TeamMeetingHistoryId");
b.HasIndex("TeamMeetingHistoryId");
b.ToTable("TeamMeetingHistoryStudents", (string)null);
});
modelBuilder.Entity("TeamTeamMeetingHistory", b =>
{
b.Property<int>("TeamMeetingHistoryId")
.HasColumnType("INTEGER");
b.Property<int>("TeamsId")
.HasColumnType("INTEGER");
b.HasKey("TeamMeetingHistoryId", "TeamsId");
b.HasIndex("TeamsId");
b.ToTable("TeamMeetingHistoryTeams", (string)null);
});
modelBuilder.Entity("CareerEventDefinition", b =>
{
b.HasOne("Core.Entities.EventDefinition", null)
.WithMany()
.HasForeignKey("EventDefinitionId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("Core.Entities.Career", null)
.WithMany()
.HasForeignKey("RelatedCareersId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("Core.Entities.EventOccurrence", b =>
{
b.HasOne("Core.Entities.EventDefinition", "EventDefinition")
.WithMany()
.HasForeignKey("EventDefinitionId")
.OnDelete(DeleteBehavior.Restrict);
b.Navigation("EventDefinition");
});
modelBuilder.Entity("Core.Entities.NoteHistory", b =>
{
b.HasOne("Core.Entities.Note", "Note")
.WithMany("NoteHistories")
.HasForeignKey("NoteId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Note");
});
modelBuilder.Entity("Core.Entities.StudentEventRanking", b =>
{
b.HasOne("Core.Entities.EventDefinition", "EventDefinition")
.WithMany()
.HasForeignKey("EventDefinitionId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("Core.Entities.Student", "Student")
.WithMany("EventRankings")
.HasForeignKey("StudentId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("EventDefinition");
b.Navigation("Student");
});
modelBuilder.Entity("Core.Entities.Team", b =>
{
b.HasOne("Core.Entities.Student", "Captain")
.WithMany()
.HasForeignKey("CaptainId")
.OnDelete(DeleteBehavior.SetNull);
b.HasOne("Core.Entities.EventDefinition", "Event")
.WithMany()
.HasForeignKey("EventId")
.OnDelete(DeleteBehavior.Restrict)
.IsRequired();
b.Navigation("Captain");
b.Navigation("Event");
});
modelBuilder.Entity("StudentTeam", b =>
{
b.HasOne("Core.Entities.Student", null)
.WithMany()
.HasForeignKey("StudentsId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("Core.Entities.Team", null)
.WithMany()
.HasForeignKey("TeamsId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("StudentTeamMeetingHistory", b =>
{
b.HasOne("Core.Entities.Student", null)
.WithMany()
.HasForeignKey("StudentsId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("Core.Entities.TeamMeetingHistory", null)
.WithMany()
.HasForeignKey("TeamMeetingHistoryId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("TeamTeamMeetingHistory", b =>
{
b.HasOne("Core.Entities.TeamMeetingHistory", null)
.WithMany()
.HasForeignKey("TeamMeetingHistoryId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("Core.Entities.Team", null)
.WithMany()
.HasForeignKey("TeamsId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("Core.Entities.Note", b =>
{
b.Navigation("NoteHistories");
});
modelBuilder.Entity("Core.Entities.Student", b =>
{
b.Navigation("EventRankings");
});
#pragma warning restore 612, 618
}
}
}
@@ -0,0 +1,104 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace Data.Migrations
{
/// <inheritdoc />
public partial class AddTeamMeetingHistory : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "TeamMeetingHistories",
columns: table => new
{
Id = table.Column<int>(type: "INTEGER", nullable: false)
.Annotation("Sqlite:Autoincrement", true),
MeetingDate = table.Column<DateTime>(type: "TEXT", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_TeamMeetingHistories", x => x.Id);
});
migrationBuilder.CreateTable(
name: "TeamMeetingHistoryStudents",
columns: table => new
{
StudentsId = table.Column<int>(type: "INTEGER", nullable: false),
TeamMeetingHistoryId = table.Column<int>(type: "INTEGER", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_TeamMeetingHistoryStudents", x => new { x.StudentsId, x.TeamMeetingHistoryId });
table.ForeignKey(
name: "FK_TeamMeetingHistoryStudents_Students_StudentsId",
column: x => x.StudentsId,
principalTable: "Students",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_TeamMeetingHistoryStudents_TeamMeetingHistories_TeamMeetingHistoryId",
column: x => x.TeamMeetingHistoryId,
principalTable: "TeamMeetingHistories",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "TeamMeetingHistoryTeams",
columns: table => new
{
TeamMeetingHistoryId = table.Column<int>(type: "INTEGER", nullable: false),
TeamsId = table.Column<int>(type: "INTEGER", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_TeamMeetingHistoryTeams", x => new { x.TeamMeetingHistoryId, x.TeamsId });
table.ForeignKey(
name: "FK_TeamMeetingHistoryTeams_TeamMeetingHistories_TeamMeetingHistoryId",
column: x => x.TeamMeetingHistoryId,
principalTable: "TeamMeetingHistories",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_TeamMeetingHistoryTeams_Teams_TeamsId",
column: x => x.TeamsId,
principalTable: "Teams",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateIndex(
name: "IX_TeamMeetingHistories_MeetingDate",
table: "TeamMeetingHistories",
column: "MeetingDate");
migrationBuilder.CreateIndex(
name: "IX_TeamMeetingHistoryStudents_TeamMeetingHistoryId",
table: "TeamMeetingHistoryStudents",
column: "TeamMeetingHistoryId");
migrationBuilder.CreateIndex(
name: "IX_TeamMeetingHistoryTeams_TeamsId",
table: "TeamMeetingHistoryTeams",
column: "TeamsId");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "TeamMeetingHistoryStudents");
migrationBuilder.DropTable(
name: "TeamMeetingHistoryTeams");
migrationBuilder.DropTable(
name: "TeamMeetingHistories");
}
}
}
@@ -370,6 +370,22 @@ namespace Data.Migrations
b.ToTable("Teams");
});
modelBuilder.Entity("Core.Entities.TeamMeetingHistory", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<DateTime>("MeetingDate")
.HasColumnType("TEXT");
b.HasKey("Id");
b.HasIndex("MeetingDate");
b.ToTable("TeamMeetingHistories");
});
modelBuilder.Entity("StudentTeam", b =>
{
b.Property<int>("StudentsId")
@@ -385,6 +401,36 @@ namespace Data.Migrations
b.ToTable("TeamStudents", (string)null);
});
modelBuilder.Entity("StudentTeamMeetingHistory", b =>
{
b.Property<int>("StudentsId")
.HasColumnType("INTEGER");
b.Property<int>("TeamMeetingHistoryId")
.HasColumnType("INTEGER");
b.HasKey("StudentsId", "TeamMeetingHistoryId");
b.HasIndex("TeamMeetingHistoryId");
b.ToTable("TeamMeetingHistoryStudents", (string)null);
});
modelBuilder.Entity("TeamTeamMeetingHistory", b =>
{
b.Property<int>("TeamMeetingHistoryId")
.HasColumnType("INTEGER");
b.Property<int>("TeamsId")
.HasColumnType("INTEGER");
b.HasKey("TeamMeetingHistoryId", "TeamsId");
b.HasIndex("TeamsId");
b.ToTable("TeamMeetingHistoryTeams", (string)null);
});
modelBuilder.Entity("CareerEventDefinition", b =>
{
b.HasOne("Core.Entities.EventDefinition", null)
@@ -473,6 +519,36 @@ namespace Data.Migrations
.IsRequired();
});
modelBuilder.Entity("StudentTeamMeetingHistory", b =>
{
b.HasOne("Core.Entities.Student", null)
.WithMany()
.HasForeignKey("StudentsId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("Core.Entities.TeamMeetingHistory", null)
.WithMany()
.HasForeignKey("TeamMeetingHistoryId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("TeamTeamMeetingHistory", b =>
{
b.HasOne("Core.Entities.TeamMeetingHistory", null)
.WithMany()
.HasForeignKey("TeamMeetingHistoryId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("Core.Entities.Team", null)
.WithMany()
.HasForeignKey("TeamsId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("Core.Entities.Note", b =>
{
b.Navigation("NoteHistories");
+313
View File
@@ -0,0 +1,313 @@
using Core.Entities;
using Core.Utility;
using Tests.Builders;
namespace Tests.Utility;
[TestFixture]
public class TeamClipboardMatcher_Tests
{
private List<Team> _availableTeams = [];
[SetUp]
public void SetUp()
{
BuilderExtensions.ResetAllBuilders();
// Create test teams
var construction = EventDefinitionBuilder.Team("Construction Challenge", 2, 4).Build();
var flight = EventDefinitionBuilder.Individual("Flight").Build();
var robotics = EventDefinitionBuilder.Team("Robotics", 2, 5).Build();
var coding = EventDefinitionBuilder.Individual("Coding").Build();
var medicalTech = EventDefinitionBuilder.Team("Medical Technology", 2, 3).Build();
_availableTeams =
[
TeamBuilder.Create(construction).WithIdentifier("2").Build(),
TeamBuilder.Create(flight).Build(),
TeamBuilder.Create(robotics).Build(),
TeamBuilder.Create(coding).Build(),
TeamBuilder.Create(medicalTech).Build()
];
}
[Test]
public void MatchTeamsFromClipboard_ExactMatch_ReturnsMatchingTeam()
{
// Arrange
var clipboardText = "Construction Challenge (2)";
// Act
var result = TeamClipboardMatcher.MatchTeamsFromClipboard(clipboardText, _availableTeams);
// Assert
Assert.That(result, Has.Count.EqualTo(1));
Assert.That(result[0].Event.Name, Is.EqualTo("Construction Challenge"));
Assert.That(result[0].Identifier, Is.EqualTo("2"));
}
[Test]
public void MatchTeamsFromClipboard_ExactMatchWithoutIdentifier_ReturnsMatchingTeam()
{
// Arrange
var clipboardText = "Flight";
// Act
var result = TeamClipboardMatcher.MatchTeamsFromClipboard(clipboardText, _availableTeams);
// Assert
Assert.That(result, Has.Count.EqualTo(1));
Assert.That(result[0].Event.Name, Is.EqualTo("Flight"));
}
[Test]
public void MatchTeamsFromClipboard_ClipboardFormatWithStudentList_ExtractsTeamName()
{
// Arrange
var clipboardText = "Construction Challenge (2) - John Doe, Jane Smith";
// Act
var result = TeamClipboardMatcher.MatchTeamsFromClipboard(clipboardText, _availableTeams);
// Assert
Assert.That(result, Has.Count.EqualTo(1));
Assert.That(result[0].Event.Name, Is.EqualTo("Construction Challenge"));
}
[Test]
public void MatchTeamsFromClipboard_MultipleTeams_ReturnsAllMatches()
{
// Arrange
var clipboardText = "Flight\r\nRobotics\r\nCoding";
// Act
var result = TeamClipboardMatcher.MatchTeamsFromClipboard(clipboardText, _availableTeams);
// Assert
Assert.That(result, Has.Count.EqualTo(3));
Assert.That(result.Select(t => t.Event.Name), Contains.Item("Flight"));
Assert.That(result.Select(t => t.Event.Name), Contains.Item("Robotics"));
Assert.That(result.Select(t => t.Event.Name), Contains.Item("Coding"));
}
[Test]
public void MatchTeamsFromClipboard_FuzzyMatch_ReturnsBestMatch()
{
// Arrange
var clipboardText = "Construcion Challange"; // Intentional typos
// Act
var result = TeamClipboardMatcher.MatchTeamsFromClipboard(clipboardText, _availableTeams);
// Assert
Assert.That(result, Has.Count.EqualTo(1));
Assert.That(result[0].Event.Name, Is.EqualTo("Construction Challenge"));
}
[Test]
public void MatchTeamsFromClipboard_CaseInsensitive_MatchesCorrectly()
{
// Arrange
var clipboardText = "FLIGHT\r\nconstruction challenge (2)";
// Act
var result = TeamClipboardMatcher.MatchTeamsFromClipboard(clipboardText, _availableTeams);
// Assert
Assert.That(result, Has.Count.EqualTo(2));
Assert.That(result.Select(t => t.Event.Name), Contains.Item("Flight"));
Assert.That(result.Select(t => t.Event.Name), Contains.Item("Construction Challenge"));
}
[Test]
public void MatchTeamsFromClipboard_SkipsEmptyLines_IgnoresEmptyEntries()
{
// Arrange
var clipboardText = "Flight\r\n\r\nRobotics\r\n \r\nCoding";
// Act
var result = TeamClipboardMatcher.MatchTeamsFromClipboard(clipboardText, _availableTeams);
// Assert
Assert.That(result, Has.Count.EqualTo(3));
}
[Test]
public void MatchTeamsFromClipboard_SkipsMetadataHeaders_IgnoresSpecialMarkers()
{
// Arrange
var clipboardText = "--Unscheduled\r\nFlight\r\n--Another Header\r\nRobotics\r\nUnscheduled";
// Act
var result = TeamClipboardMatcher.MatchTeamsFromClipboard(clipboardText, _availableTeams);
// Assert
Assert.That(result, Has.Count.EqualTo(2));
Assert.That(result.Select(t => t.Event.Name), Contains.Item("Flight"));
Assert.That(result.Select(t => t.Event.Name), Contains.Item("Robotics"));
}
[Test]
public void MatchTeamsFromClipboard_NoMatches_ReturnsEmptyList()
{
// Arrange
var clipboardText = "NonExistent Team Name";
// Act
var result = TeamClipboardMatcher.MatchTeamsFromClipboard(clipboardText, _availableTeams);
// Assert
Assert.That(result, Is.Empty);
}
[Test]
public void MatchTeamsFromClipboard_BelowThreshold_ReturnsEmptyList()
{
// Arrange
var clipboardText = "XYZ"; // Very different from any team name
var highThreshold = 95; // Very high threshold
// Act
var result = TeamClipboardMatcher.MatchTeamsFromClipboard(clipboardText, _availableTeams, highThreshold);
// Assert
Assert.That(result, Is.Empty);
}
[Test]
public void MatchTeamsFromClipboard_CustomThreshold_RespectsThreshold()
{
// Arrange
var clipboardText = "Construction Challeng"; // Close match, should work with lower threshold
var lowThreshold = 70;
// Act
var result = TeamClipboardMatcher.MatchTeamsFromClipboard(clipboardText, _availableTeams, lowThreshold);
// Assert
Assert.That(result, Has.Count.EqualTo(1));
Assert.That(result[0].Event.Name, Is.EqualTo("Construction Challenge"));
}
[Test]
public void MatchTeamsFromClipboard_EmptyClipboard_ReturnsEmptyList()
{
// Arrange
var clipboardText = "";
// Act
var result = TeamClipboardMatcher.MatchTeamsFromClipboard(clipboardText, _availableTeams);
// Assert
Assert.That(result, Is.Empty);
}
[Test]
public void MatchTeamsFromClipboard_NullClipboard_ReturnsEmptyList()
{
// Arrange
string? clipboardText = null;
// Act
var result = TeamClipboardMatcher.MatchTeamsFromClipboard(clipboardText!, _availableTeams);
// Assert
Assert.That(result, Is.Empty);
}
[Test]
public void MatchTeamsFromClipboard_EmptyTeamsList_ReturnsEmptyList()
{
// Arrange
var clipboardText = "Flight";
var emptyTeams = new List<Team>();
// Act
var result = TeamClipboardMatcher.MatchTeamsFromClipboard(clipboardText, emptyTeams);
// Assert
Assert.That(result, Is.Empty);
}
[Test]
public void MatchTeamsFromClipboard_DuplicateTeamNames_ReturnsSingleInstance()
{
// Arrange
var clipboardText = "Flight\r\nFlight\r\nFlight";
// Act
var result = TeamClipboardMatcher.MatchTeamsFromClipboard(clipboardText, _availableTeams);
// Assert
Assert.That(result, Has.Count.EqualTo(1));
Assert.That(result[0].Event.Name, Is.EqualTo("Flight"));
}
[Test]
public void MatchTeamsFromClipboard_MultipleLinesWithDifferentFormats_HandlesAllFormats()
{
// Arrange
var clipboardText = "Flight\r\nRobotics - Student List\r\nMedical Technology (1) - More Students";
// Act
var result = TeamClipboardMatcher.MatchTeamsFromClipboard(clipboardText, _availableTeams);
// Assert
Assert.That(result, Has.Count.EqualTo(3));
Assert.That(result.Select(t => t.Event.Name), Contains.Item("Flight"));
Assert.That(result.Select(t => t.Event.Name), Contains.Item("Robotics"));
Assert.That(result.Select(t => t.Event.Name), Contains.Item("Medical Technology"));
}
[Test]
public void MatchTeamsFromClipboard_WhitespaceAroundTeamName_TrimsCorrectly()
{
// Arrange
var clipboardText = " Flight \r\n Robotics ";
// Act
var result = TeamClipboardMatcher.MatchTeamsFromClipboard(clipboardText, _availableTeams);
// Assert
Assert.That(result, Has.Count.EqualTo(2));
Assert.That(result.Select(t => t.Event.Name), Contains.Item("Flight"));
Assert.That(result.Select(t => t.Event.Name), Contains.Item("Robotics"));
}
[Test]
public void MatchTeamsFromClipboard_ReturnsTeamsFromInputCollection_MaintainsReferenceEquality()
{
// Arrange
var clipboardText = "Flight";
var inputTeam = _availableTeams.First(t => t.Event.Name == "Flight");
// Act
var result = TeamClipboardMatcher.MatchTeamsFromClipboard(clipboardText, _availableTeams);
// Assert
Assert.That(result[0], Is.SameAs(inputTeam));
}
[Test]
public void MatchTeamsFromClipboard_BestMatchSelected_ReturnsHighestScoringMatch()
{
// Arrange
// Create teams with similar names
var construction1 = EventDefinitionBuilder.Team("Construction Challenge", 2, 4).Build();
var construction2 = EventDefinitionBuilder.Team("Construction Challenge Advanced", 2, 4).Build();
var teams = new[]
{
TeamBuilder.Create(construction1).Build(),
TeamBuilder.Create(construction2).Build()
};
var clipboardText = "Construction Challenge"; // Should match the first one exactly
// Act
var result = TeamClipboardMatcher.MatchTeamsFromClipboard(clipboardText, teams);
// Assert
Assert.That(result, Has.Count.EqualTo(1));
// The exact match should be selected (higher score)
Assert.That(result[0].Event.Name, Is.EqualTo("Construction Challenge"));
}
}
+73 -24
View File
@@ -7,6 +7,7 @@
@using WebApp.Authentication
@using Core.Utility
@inject IEventOccurrenceService EventOccurrenceService
@inject ITeamMeetingHistoryService TeamMeetingHistoryService
@inject ILogger<Index> Logger
@inject IDialogService DialogService
@@ -33,18 +34,8 @@
else
{
<MudStack Spacing="2">
<MudButtonGroup Variant="Variant.Outlined" Size="Size.Small">
<MudButton Color="@(_currentView == CalendarView.Month ? Color.Primary : Color.Default)"
OnClick="() => { _currentView = CalendarView.Month; StateHasChanged(); }">
Month
</MudButton>
<MudButton Color="@(_currentView == CalendarView.Day ? Color.Primary : Color.Default)"
OnClick="() => { _currentView = CalendarView.Day; StateHasChanged(); }">
Day
</MudButton>
</MudButtonGroup>
<MudCalendar T="CalendarEventItem"
<MudCalendar T="CalendarItemWrapper"
Items="_calendarItems"
View="_currentView"
CurrentDay="@_calendarDate"
@@ -76,7 +67,7 @@
</MudPaper>
@code {
private List<CalendarEventItem>? _calendarItems;
private List<CalendarItemWrapper>? _calendarItems;
private DateTime _calendarDate = DateTime.Today;
private CalendarView _currentView = CalendarView.Month;
@@ -105,7 +96,9 @@
// Load teams for all event definitions
var teamsByEventId = await EventOccurrenceService.GetTeamsByEventDefinitionIdsAsync(eventDefinitionIds);
List<CalendarEventItem> items = [];
List<CalendarItemWrapper> items = [];
// Add event occurrences
foreach (var occ in eventOccurrences)
{
try
@@ -127,8 +120,8 @@
})
: [];
var calendarItem = new CalendarEventItem(occ, studentFirstNames);
items.Add(calendarItem);
var calendarEventItem = new CalendarEventItem(occ, studentFirstNames);
items.Add(new CalendarItemWrapper(calendarEventItem));
}
catch (Exception ex)
{
@@ -138,8 +131,37 @@
}
}
// Load and add meeting histories
try
{
Logger.LogInformation("Loading meeting histories");
var meetingHistories = await TeamMeetingHistoryService.GetMeetingHistoriesAsync();
foreach (var meetingHistory in meetingHistories)
{
try
{
var calendarMeetingItem = new CalendarMeetingItem(meetingHistory);
items.Add(new CalendarItemWrapper(calendarMeetingItem));
}
catch (Exception ex)
{
Logger.LogError(ex, "Error creating CalendarMeetingItem for meeting history Id={Id}, Date={Date}",
meetingHistory?.Id, meetingHistory?.MeetingDate);
// Continue processing other items
}
}
Logger.LogInformation("Added {Count} meeting histories to calendar", meetingHistories.Count());
}
catch (Exception ex)
{
Logger.LogError(ex, "Error loading meeting histories");
// Continue - don't fail the entire calendar load if meetings fail
}
_calendarItems = items;
Logger.LogInformation("Created {Count} calendar items from {OccurrenceCount} occurrences",
Logger.LogInformation("Created {Count} calendar items from {OccurrenceCount} occurrences and meetings",
_calendarItems.Count, eventOccurrences.Count());
// Find the next date with events
@@ -168,7 +190,7 @@
}
var today = DateTime.Today;
var nextEvent = _calendarItems
var nextItem = _calendarItems
.Where(item =>
{
try
@@ -184,17 +206,17 @@
.OrderBy(item => item.Start)
.FirstOrDefault();
if (nextEvent != null)
if (nextItem != null)
{
return nextEvent.Start.Date;
return nextItem.Start.Date;
}
// Fallback to first event if no future events
var firstEvent = _calendarItems
// Fallback to first item if no future items
var firstItem = _calendarItems
.OrderBy(item => item.Start)
.FirstOrDefault();
return firstEvent != null ? firstEvent.Start.Date : DateTime.Today;
return firstItem != null ? firstItem.Start.Date : DateTime.Today;
}
catch (Exception ex)
{
@@ -235,12 +257,19 @@
return string.Join("\n", parts);
}
private async Task OnItemClicked(CalendarEventItem calendarEventItem)
private async Task OnItemClicked(CalendarItemWrapper wrapper)
{
if (_calendarItems == null)
return;
await ShowEventDetails(calendarEventItem);
if (wrapper.ItemType == CalendarItemType.Event && wrapper.EventItem != null)
{
await ShowEventDetails(wrapper.EventItem);
}
else if (wrapper.ItemType == CalendarItemType.Meeting && wrapper.MeetingItem != null)
{
await ShowMeetingDetails(wrapper.MeetingItem);
}
}
private async Task ShowEventDetails(CalendarEventItem item)
@@ -264,5 +293,25 @@
await DialogService.ShowAsync<EventOccurrenceDetailsDialog>("Event Details", parameters, options);
}
private async Task ShowMeetingDetails(CalendarMeetingItem item)
{
if (item.MeetingHistoryData == null) return;
var parameters = new DialogParameters
{
["MeetingHistoryId"] = item.MeetingHistoryData.Id
};
var options = new DialogOptions
{
CloseOnEscapeKey = true,
CloseButton = true,
MaxWidth = MaxWidth.Large,
FullWidth = true
};
await DialogService.ShowAsync<MeetingHistoryDetailDialog>("Meeting Details", parameters, options);
}
}
@@ -0,0 +1,397 @@
@page "/meeting-schedule/history"
@attribute [Authorize]
@using Core.Entities
@using Microsoft.EntityFrameworkCore
@using WebApp.Components.Shared.Components
@using WebApp.Services
@inject ITeamMeetingHistoryService TeamMeetingHistoryService
@inject AppDbContext Context
@inject IDialogService DialogService
@inject ISnackbar Snackbar
@inject IConfiguration Configuration
@inject IMeetingScheduleDataService DataService
@inject IMeetingScheduleStateService StateService
@inject NavigationManager NavigationManager
@implements IAsyncDisposable
<PageHeader Title="Team Meeting Schedule History">
<ActionButtons>
<MudButton StartIcon="@Icons.Material.Filled.Add"
Variant="Variant.Outlined"
Color="Color.Primary"
Href="/meeting-schedule">
Back to Schedule
</MudButton>
</ActionButtons>
</PageHeader>
<MudPaper Elevation="2" Class="pa-3 pa-md-6 mt-4">
@if (_isLoading)
{
<MudProgressLinear Color="Color.Primary" Indeterminate="true" Class="my-4" />
}
else
{
<MudStack Spacing="3">
@if (_meetingHistories.Any())
{
<MudPaper Elevation="1" Class="pa-3" Style="overflow-x: auto; -webkit-overflow-scrolling: touch;">
<table class="history-grid-table" style="min-width: max-content; width: 100%; border-collapse: collapse;">
<colgroup>
<col style="width: 72px;" />
<col style="width: 40px;" />
@for (var c = 0; c < _allTeams.Count; c++)
{
<col style="width: 28px;" />
}
</colgroup>
<thead>
<tr>
<th class="history-cell history-cell-date">
<span class="mud-typography mud-typography-caption">Date</span>
</th>
<th class="history-cell history-cell-actions">
<span class="mud-typography mud-typography-caption" style="writing-mode: vertical-rl; text-orientation: mixed; transform: rotate(180deg);">Actions</span>
</th>
@{
var teamIndex = 0;
}
@foreach (var team in _allTeams)
{
var isEven = teamIndex % 2 == 0;
var colClass = isEven ? "history-cell history-cell-col-even" : "history-cell history-cell-col-odd";
<th class="@colClass">
<span class="mud-typography mud-typography-caption" style="writing-mode: vertical-rl; text-orientation: mixed; transform: rotate(180deg);">@team.ToString()</span>
</th>
teamIndex++;
}
</tr>
<tr>
<th class="history-cell history-cell-date history-cell-times-met">Times Met</th>
<th class="history-cell history-cell-actions "></th>
@{
var summaryTeamIndex = 0;
}
@foreach (var team in _allTeams)
{
var timesMet = GetTimesMetForTeam(team);
var isEven = summaryTeamIndex % 2 == 0;
var colClass = isEven ? "history-cell history-cell-col-even history-cell-times-met" : "history-cell history-cell-col-odd history-cell-times-met";
<th class="@colClass">@timesMet</th>
summaryTeamIndex++;
}
</tr>
</thead>
<tbody>
@{
var rowIndex = 0;
}
@foreach (var history in _meetingHistories)
{
var rowTeamIndex = 0;
var rowClass = rowIndex % 2 == 0 ? "history-row-even" : "history-row-odd";
<tr class="@rowClass">
<td class="history-cell history-cell-date ">
<MudButton Variant="Variant.Text"
Color="Color.Primary"
Size="Size.Small"
OnClick="@(() => ViewMeetingDetails(history))"
Style="text-transform: none; padding: 0 2px; min-width: unset;">
@history.MeetingDate.ToString("MM/dd/yy")
</MudButton>
</td>
<td class="history-cell history-cell-actions">
<MudTooltip Text="Load into Planner">
<MudIconButton Icon="@Icons.Material.Filled.Upload"
Size="Size.Small"
Color="Color.Secondary"
OnClick="@(() => LoadMeetingIntoPlanner(history))"
Variant="Variant.Text"
Style="padding: 2px;" />
</MudTooltip>
</td>
@foreach (var team in _allTeams)
{
var met = TeamMetOnDate(history, team);
var isEven = rowTeamIndex % 2 == 0;
var colClass = isEven ? "history-cell history-cell-col-even" : "history-cell history-cell-col-odd";
<td class="@colClass">
@if (met)
{
<span class="mud-typography mud-typography-body1" style="font-weight: bold;">×</span>
}
</td>
rowTeamIndex++;
}
</tr>
rowIndex++;
}
</tbody>
</table>
</MudPaper>
}
else
{
<MudAlert Severity="Severity.Info">No meeting history found. Save a meeting schedule to get started.</MudAlert>
}
</MudStack>
}
</MudPaper>
<style>
.history-grid-table {
--history-border: 1px solid var(--mud-palette-divider);
--history-shade: var(--mud-palette-background-grey);
}
.history-grid-table th,
.history-grid-table td {
padding: 2px 4px;
border-right: var(--history-border);
border-bottom: var(--history-border);
vertical-align: middle;
}
.history-grid-table thead th {
border-top: var(--history-border);
background-color: var(--mud-palette-surface);
}
.history-grid-table thead .history-cell-col-odd {
background-color: var(--mud-palette-surface);
}
.history-grid-table thead th:first-child,
.history-grid-table tbody td:first-child {
border-left: var(--history-border);
}
.history-grid-table .history-cell-date {
padding: 2px 4px;
text-align: left;
min-width: 72px;
}
.history-grid-table .history-cell-actions {
padding: 2px;
text-align: center;
min-width: 40px;
}
.history-grid-table thead .history-cell-col-even {
background-color: var(--history-shade);
}
.history-grid-table .history-cell-times-met {
font-weight: bold;
background-color: var(--history-shade);
}
.history-grid-table tbody .history-row-odd td {
background-color: var(--history-shade);
}
.history-grid-table tbody .history-row-even td.history-cell-col-even,
.history-grid-table tbody .history-row-odd td.history-cell-col-even {
background-color: var(--history-shade);
}
.history-grid-table tbody .history-row-odd td.history-cell-col-odd {
background-color: var(--history-shade);
}
</style>
@code {
private List<TeamMeetingHistory> _meetingHistories = [];
private List<Team> _allTeams = [];
private Dictionary<int, int> _timesMetDict = new();
private bool _isLoading = true;
private CancellationTokenSource? _cancellationTokenSource;
private bool _isDisposed = false;
protected override void OnInitialized()
{
_cancellationTokenSource = new CancellationTokenSource();
}
protected override async Task OnInitializedAsync()
{
await LoadData();
}
private async Task LoadData()
{
if (_isDisposed) return;
try
{
_isLoading = true;
StateHasChanged();
// Load all teams for columns
_allTeams = await Context.Teams
.AsNoTracking()
.Include(t => t.Event)
.OrderBy(t => t.Event.Name)
.ThenBy(t => t.Identifier)
.ToListAsync();
// Load meeting histories
await RefreshMeetingHistories();
// Calculate times met
CalculateTimesMet();
}
catch (TaskCanceledException)
{
// Component was disposed, ignore
}
catch (JSDisconnectedException)
{
// JS connection lost, ignore
}
catch (Exception ex)
{
if (!_isDisposed)
{
Snackbar.Add($"Error loading meeting history: {ex.Message}", Severity.Error);
}
}
finally
{
if (!_isDisposed)
{
_isLoading = false;
StateHasChanged();
}
}
}
private async Task RefreshMeetingHistories()
{
_meetingHistories = (await TeamMeetingHistoryService.GetMeetingHistoriesAsync()).ToList();
// Extract all unique teams from meeting histories and merge with all teams
var teamsInHistory = _meetingHistories
.SelectMany(mh => mh.Teams)
.DistinctBy(t => t.Id)
.ToList();
// Merge with all teams, ensuring all teams are included
var allTeamIds = _allTeams.Select(t => t.Id).ToHashSet();
var newTeams = teamsInHistory.Where(t => !allTeamIds.Contains(t.Id)).ToList();
_allTeams = _allTeams.Concat(newTeams).OrderBy(t => t.Event?.Name ?? "").ThenBy(t => t.Identifier).ToList();
}
private void CalculateTimesMet()
{
_timesMetDict.Clear();
foreach (var team in _allTeams)
{
_timesMetDict[team.Id] = 0;
}
foreach (var history in _meetingHistories)
{
var teamIds = history.Teams.Select(t => t.Id).ToHashSet();
foreach (var teamId in teamIds)
{
if (_timesMetDict.ContainsKey(teamId))
{
_timesMetDict[teamId]++;
}
}
}
}
private int GetTimesMetForTeam(Team team)
{
return _timesMetDict.GetValueOrDefault(team.Id, 0);
}
private bool TeamMetOnDate(TeamMeetingHistory history, Team team)
{
return history.Teams.Any(t => t.Id == team.Id);
}
private async Task ViewMeetingDetails(TeamMeetingHistory history)
{
var parameters = new DialogParameters
{
["MeetingHistoryId"] = history.Id
};
var options = new DialogOptions
{
MaxWidth = MaxWidth.Large,
FullWidth = true,
CloseButton = true
};
var dialog = await DialogService.ShowAsync<MeetingHistoryDetailDialog>("Meeting Details", parameters, options);
var result = await dialog.Result;
if (!result.Canceled)
{
// Refresh data if meeting was updated or deleted
await RefreshMeetingHistories();
CalculateTimesMet();
if (!_isDisposed)
{
StateHasChanged();
}
}
}
private async Task LoadMeetingIntoPlanner(TeamMeetingHistory history)
{
if (_isDisposed) return;
try
{
// Get all teams and students from database
var allTeams = await DataService.LoadTeamsAsync();
var allStudents = await DataService.LoadStudentsAsync();
// Match teams from history to all teams by ID for reference equality
var historyTeamIds = history.Teams.Select(t => t.Id).ToHashSet();
var scheduledTeams = allTeams.Where(t => historyTeamIds.Contains(t.Id));
// Calculate absent students (all students not in the meeting history's student list)
var presentStudentIds = history.Students.Select(s => s.Id).ToHashSet();
var absentStudents = allStudents.Where(s => !presentStudentIds.Contains(s.Id));
// Save state to localStorage
await StateService.SaveScheduledTeamsAsync(scheduledTeams);
await StateService.SaveAbsentStudentsAsync(absentStudents);
// Clear extended teams and excluded students when loading from history
await StateService.SaveExtendedTeamsAsync([]);
await StateService.SaveExcludedStudentsAsync(new Dictionary<(int teamId, int timeSlotIndex, int studentId), bool>());
// Navigate to planner
NavigationManager.NavigateTo("/meeting-schedule");
if (!_isDisposed)
{
Snackbar.Add($"Loaded meeting from {history.MeetingDate:MM/dd/yyyy} into planner", Severity.Success);
}
}
catch (TaskCanceledException)
{
// Component was disposed, ignore
}
catch (JSDisconnectedException)
{
// JS connection lost, ignore
}
catch (Exception ex)
{
if (!_isDisposed)
{
Snackbar.Add($"Error loading meeting into planner: {ex.Message}", Severity.Error);
}
}
}
public async ValueTask DisposeAsync()
{
if (!_isDisposed)
{
_isDisposed = true;
_cancellationTokenSource?.Cancel();
_cancellationTokenSource?.Dispose();
_cancellationTokenSource = null;
}
await ValueTask.CompletedTask;
}
}
@@ -2,16 +2,41 @@
@attribute [Authorize]
@using System.Text
@using Core.Calculation
@using Core.Models
@using Core.Utility
@using Microsoft.EntityFrameworkCore
@using WebApp.Components.Shared.Components
@using Core.Utility
@using WebApp.Components.Features.MeetingSchedule
@using WebApp.Models
@using WebApp.Services
@inject IConfiguration Configuration
@inject AppDbContext Context
@inject ClipboardService ClipboardService
@inject IDialogService DialogService
@inject ISnackbar Snackbar
@inject IMeetingScheduleStateService StateService
@inject IMeetingScheduleDataService DataService
@inject IMeetingScheduleClipboardService ClipboardFormatService
@inject LocalStorageService LocalStorage
<PageHeader Title="@($"{Configuration["ChapterSettings:Shortname"]} TSA Schedule {Configuration["ChapterSettings:CompetitionYear"]}")">
<PageHeader Title="@($"Meeting Scheduler Planner")">
<ActionButtons>
<MudTooltip Text="View meeting history">
<MudButton StartIcon="@Icons.Material.Filled.History"
Variant="Variant.Outlined"
Color="Color.Default"
Href="/meeting-schedule/history">
View History
</MudButton>
</MudTooltip>
<MudTooltip Text="Save current schedule as meeting history">
<MudButton StartIcon="@Icons.Material.Filled.Save"
Variant="Variant.Outlined"
Color="Color.Primary"
OnClick="OpenSaveHistoryDialog"
Disabled="@(!_scheduledTeams.Any())">
Save to History
</MudButton>
</MudTooltip>
<PageNoteButton PageIdentifier="Meeting Schedule" />
</ActionButtons>
</PageHeader>
@@ -22,46 +47,86 @@
<MudText Typo="Typo.h4">Time Slots</MudText>
<MudPaper Class="pa-2 ma-2" Elevation="3">
<MudGrid>
<MudItem xs="6" sm="3" lg="2">
<MudNumericField Value="_parameters.TimeSlots"
ValueChanged="async (int val) => await OnTimeSlotCountChanged(val)"
Label="Time Slots" Min="1" Max="4">
</MudNumericField>
</MudItem>
<MudFlexBreak/>
<MudItem xs="12" sm="6" lg="4">
<MudTooltip Text="Schedule teams with Level of Effort >= 3" Inline="false">
<MudButton Variant="Variant.Outlined" OnClick="AddHighLevelOfEffort" FullWidth="true">Add High Effort</MudButton>
</MudTooltip>
<MudPaper Elevation="0" Class="pa-1" Style="border: 1px solid var(--mud-palette-lines-default); border-radius: var(--mud-default-borderradius);">
<MudStack Row="true" AlignItems="AlignItems.Center" Spacing="2">
<MudText Typo="Typo.body2">Time Slots</MudText>
<MudStack Row="true" AlignItems="AlignItems.Center" Spacing="0" Style="border: 1px solid var(--mud-palette-lines-default); border-radius: var(--mud-default-borderradius);">
<MudIconButton Icon="@Icons.Material.Filled.Remove"
OnClick="DecrementTimeSlots"
Disabled="@(_parameters.TimeSlots <= 1)"
Size="Size.Small"
Variant="Variant.Text"
Style="border-radius: var(--mud-default-borderradius) 0 0 var(--mud-default-borderradius);" />
<MudButton Disabled="true"
Variant="Variant.Text"
Style="min-width: 50px; width: 50px; pointer-events: none; border-left: 1px solid var(--mud-palette-lines-default); border-right: 1px solid var(--mud-palette-lines-default); border-radius: 0;">
@_parameters.TimeSlots
</MudButton>
<MudIconButton Icon="@Icons.Material.Filled.Add"
OnClick="IncrementTimeSlots"
Disabled="@(_parameters.TimeSlots >= 4)"
Size="Size.Small"
Variant="Variant.Text"
Style="border-radius: 0 var(--mud-default-borderradius) var(--mud-default-borderradius) 0;" />
</MudStack>
</MudStack>
</MudPaper>
</MudItem>
<MudItem xs="12" sm="6" lg="4">
<MudButton Variant="Variant.Outlined" OnClick="AddRegionals" FullWidth="true">Add Regionals</MudButton>
<AddRemoveFilter Label="High Effort"
OnAdd="AddHighLevelOfEffort"
OnRemove="RemoveHighLevelOfEffort"
AddTooltip="Schedule teams with Level of Effort >= 3"
RemoveTooltip="Remove teams with Level of Effort >= 3" />
</MudItem>
<MudItem xs="12" sm="6" lg="4">
<MudButton Variant="Variant.Outlined" OnClick="RemoveIndividual" FullWidth="true">Remove Individual</MudButton>
<AddRemoveFilter Label="Regionals"
OnAdd="AddRegionals"
OnRemove="RemoveRegionals"
AddTooltip="Add regional event teams"
RemoveTooltip="Remove regional event teams" />
</MudItem>
<MudItem xs="12" sm="6" lg="4">
<MudButton Variant="Variant.Outlined" OnClick="RemoveLowLevelOfEffort" FullWidth="true">Remove Low Effort</MudButton>
<AddRemoveFilter Label="Individual"
OnAdd="AddIndividual"
OnRemove="RemoveIndividual"
AddTooltip="Add individual event teams"
RemoveTooltip="Remove individual event teams" />
</MudItem>
<MudItem xs="12" sm="6" lg="4">
<AddRemoveFilter Label="Low Effort"
OnAdd="AddLowLevelOfEffort"
OnRemove="RemoveLowLevelOfEffort"
AddTooltip="Add teams with Level of Effort <= 1"
RemoveTooltip="Remove teams with Level of Effort <= 1" />
</MudItem>
<MudItem xs="12" sm="6" lg="4">
<MudButton Variant="Variant.Outlined" OnClick="Invert" FullWidth="true">Invert</MudButton>
</MudItem>
<MudItem xs="12" sm="6" lg="4">
<MudTooltip Text="Load teams from clipboard text by matching team names">
<MudButton Variant="Variant.Outlined" OnClick="LoadTeamsFromClipboard" FullWidth="true" Disabled="@_isLoadingClipboard">Load from Clipboard</MudButton>
</MudTooltip>
</MudItem>
<MudItem xs="12" sm="6" lg="4">
<MudButton Variant="Variant.Outlined" Color="Color.Warning" OnClick="Reset" FullWidth="true">Reset</MudButton>
</MudItem>
<MudItem xs="12">
<MudButton Variant="@(IsDirty() ? Variant.Outlined : Variant.Filled)"
Class="ma-3"
OnClick="Solve"
Color="Color.Primary"
Disabled="@_isSolving">
Solve
</MudButton>
<MudTooltip Text="Copy to Clipboard">
<MudIconButton OnClick="CopyToClipboard" Icon="@Icons.Material.Filled.ContentCopy"></MudIconButton>
</MudTooltip>
<MudStack Row="true" AlignItems="AlignItems.Center" Spacing="2">
<MudSpacer />
<MudTooltip Text="Copy to Clipboard">
<MudIconButton OnClick="CopyToClipboard" Icon="@Icons.Material.Filled.ContentCopy"></MudIconButton>
</MudTooltip>
<MudButton Variant="@(IsDirty() ? Variant.Outlined : Variant.Filled)"
OnClick="Solve"
Color="Color.Primary"
Disabled="@_isSolving">
Solve
</MudButton>
</MudStack>
</MudItem>
</MudGrid>
</MudPaper>
@@ -124,6 +189,7 @@
private TeamSchedulerSolution _solution = null!;
private TeamSchedulerOptions _parameters = null!;
bool _isSolving;
private bool _isLoadingClipboard = false;
private IEnumerable<Team> _scheduledTeams = [];
private IEnumerable<Student> _absentStudents = [];
private IEnumerable<Team> _possibleAdditions = [];
@@ -152,6 +218,22 @@
await Task.CompletedTask;
}
private async Task IncrementTimeSlots()
{
if (_parameters.TimeSlots < 4)
{
await OnTimeSlotCountChanged(_parameters.TimeSlots + 1);
}
}
private async Task DecrementTimeSlots()
{
if (_parameters.TimeSlots > 1)
{
await OnTimeSlotCountChanged(_parameters.TimeSlots - 1);
}
}
private void OnExtendedTeamsChanged(IEnumerable<Team> teams)
{
_extendedTeams = teams;
@@ -160,37 +242,59 @@
private void AddRegionals()
{
_scheduledTeams
= _teams.Where(e => e.Event.RegionalEvent).Concat(_scheduledTeams).Distinct();
_scheduledTeams = _scheduledTeams.AddRegionals(_teams);
StateHasChanged();
}
private void AddHighLevelOfEffort()
{
_scheduledTeams
= _teams.Where(e => e.Event.LevelOfEffort >= 3).Concat(_scheduledTeams).Distinct();
_scheduledTeams = _scheduledTeams.AddHighLevelOfEffort(_teams);
StateHasChanged();
}
private void RemoveHighLevelOfEffort()
{
var highEffortTeamIds = _teams.Where(t => t.Event.LevelOfEffort >= 3).Select(t => t.Id).ToHashSet();
_scheduledTeams = _scheduledTeams.Where(t => !highEffortTeamIds.Contains(t.Id));
StateHasChanged();
}
private void RemoveRegionals()
{
var regionalTeamIds = _teams.Where(t => t.Event.RegionalEvent).Select(t => t.Id).ToHashSet();
_scheduledTeams = _scheduledTeams.Where(t => !regionalTeamIds.Contains(t.Id));
StateHasChanged();
}
private void AddIndividual()
{
var individualTeams = _teams.Where(t => t.Event.EventFormat == EventFormat.Individual);
_scheduledTeams = _scheduledTeams.Concat(individualTeams).Distinct();
StateHasChanged();
}
private void RemoveIndividual()
{
_scheduledTeams
= _scheduledTeams.Where(t => t.Event.EventFormat != EventFormat.Individual);
_scheduledTeams = _scheduledTeams.RemoveIndividual();
StateHasChanged();
}
private void AddLowLevelOfEffort()
{
var lowEffortTeams = _teams.Where(t => t.Event.LevelOfEffort <= 1);
_scheduledTeams = _scheduledTeams.Concat(lowEffortTeams).Distinct();
StateHasChanged();
}
private void RemoveLowLevelOfEffort()
{
_scheduledTeams
= _scheduledTeams.Where(t => t.Event.LevelOfEffort > 1);
_scheduledTeams = _scheduledTeams.RemoveLowLevelOfEffort();
StateHasChanged();
}
private void Invert()
{
var rt = _scheduledTeams.ToArray();
_scheduledTeams
= _teams.Where(t => !rt.Contains(t));
_scheduledTeams = _scheduledTeams.Invert(_teams);
StateHasChanged();
}
@@ -253,32 +357,15 @@
]
);
_teams
= await Context.Teams
.AsNoTracking()
.Include(e => e.Event)
.Include(e => e.Students)
.OrderBy(e => e.Event.Name)
.ThenBy(e => e.Identifier)
.ToArrayAsync();
_students =
await Context.Students
.AsNoTracking()
.Include(e => e.Teams)
.ThenInclude(t => t.Event)
.Include(e => e.Teams)
.ThenInclude(t => t.Captain)
.Include(e => e.EventRankings)
.ThenInclude(e => e.EventDefinition)
.OrderBy(e => e.FirstName).ToArrayAsync();
_teams = await DataService.LoadTeamsAsync();
_students = await DataService.LoadStudentsAsync();
// Load saved selections from localStorage
await LoadScheduledTeams();
await LoadAbsentStudents();
await LoadTimeSlotCount();
await LoadExtendedTeams();
await LoadExcludedStudents();
_scheduledTeams = await StateService.LoadScheduledTeamsAsync(_teams);
_absentStudents = await StateService.LoadAbsentStudentsAsync(_students);
_parameters.TimeSlots = await StateService.LoadTimeSlotCountAsync(2);
_extendedTeams = await StateService.LoadExtendedTeamsAsync(_teams);
_excludedStudents = await StateService.LoadExcludedStudentsAsync();
// Initialize last saved state from loaded values
_lastSavedState = await MeetingScheduleState.FromLocalStorage(LocalStorage, _teams, _students);
@@ -294,84 +381,6 @@
}
}
private async Task SaveScheduledTeams()
{
var teamIds = _scheduledTeams.Select(t => t.Id).ToArray();
await LocalStorage.SetIntArrayAsync("MeetingSchedule_ScheduledTeams", teamIds);
}
private async Task LoadScheduledTeams()
{
var teamIds = await LocalStorage.GetIntArrayAsync("MeetingSchedule_ScheduledTeams");
if (teamIds.Length > 0)
{
_scheduledTeams = _teams.Where(t => teamIds.Contains(t.Id)).ToArray();
}
}
private async Task SaveAbsentStudents()
{
var studentIds = _absentStudents.Select(s => s.Id).ToArray();
await LocalStorage.SetIntArrayAsync("MeetingSchedule_AbsentStudents", studentIds);
}
private async Task LoadAbsentStudents()
{
var studentIds = await LocalStorage.GetIntArrayAsync("MeetingSchedule_AbsentStudents");
if (studentIds.Length > 0)
{
_absentStudents = _students.Where(s => studentIds.Contains(s.Id)).ToArray();
}
}
private async Task SaveTimeSlotCount()
{
await LocalStorage.SetIntAsync("MeetingSchedule_TimeSlotCount", _parameters.TimeSlots);
}
private async Task LoadTimeSlotCount()
{
var timeSlots = await LocalStorage.GetIntAsync("MeetingSchedule_TimeSlotCount", defaultValue: 2);
if (timeSlots > 0)
{
_parameters.TimeSlots = timeSlots;
}
}
private async Task SaveExtendedTeams()
{
var teamIds = _extendedTeams.Select(t => t.Id).ToArray();
await LocalStorage.SetIntArrayAsync("MeetingSchedule_ExtendedTeams", teamIds);
}
private async Task LoadExtendedTeams()
{
var teamIds = await LocalStorage.GetIntArrayAsync("MeetingSchedule_ExtendedTeams");
if (teamIds.Length > 0)
{
_extendedTeams = _teams.Where(t => teamIds.Contains(t.Id)).ToArray();
}
}
private async Task SaveExcludedStudents()
{
var exclusions = _excludedStudents.Keys
.Where(k => _excludedStudents[k])
.Select(k => new ExcludedStudent(k.teamId, k.timeSlotIndex, k.studentId))
.ToArray();
await LocalStorage.SetJsonAsync("MeetingSchedule_ExcludedStudents", exclusions);
}
private async Task LoadExcludedStudents()
{
var exclusions = await LocalStorage.GetJsonAsync<ExcludedStudent[]>("MeetingSchedule_ExcludedStudents");
if (exclusions != null && exclusions.Length > 0)
{
_excludedStudents = exclusions.ToDictionary(
e => (e.TeamId, e.TimeSlotIndex, e.StudentId),
_ => true);
}
}
private int GetTimeSlotIndex(string timeSlotName)
{
@@ -405,37 +414,12 @@
return _excludedStudents.TryGetValue(key, out var isExcluded) && isExcluded;
}
/// <summary>
/// Creates teams with excluded students filtered out for overlap calculation.
/// </summary>
private Team[] GetTeamsWithoutExcludedStudents(Team[] teams, int timeSlotIndex)
{
return teams.Select(team =>
{
// Find excluded students for this team in this time slot
// More efficient: iterate through team students and check exclusions
var includedStudents = team.Students
.Where(s => !IsStudentExcluded(team.Id, timeSlotIndex, s.Id))
.ToList();
// If no students are excluded, return original team
if (includedStudents.Count == team.Students.Count)
return team;
// Create a temporary team with excluded students removed
return new Team
{
Id = team.Id,
Event = team.Event,
Students = includedStudents,
Captain = team.Captain,
Identifier = team.Identifier
};
}).ToArray();
var absentStudentIds = _absentStudents.Select(s => s.Id).ToHashSet();
return OverlapCalculationHelper.GetTeamsWithoutExcludedStudents(teams, timeSlotIndex, _excludedStudents, absentStudentIds);
}
private record ExcludedStudent(int TeamId, int TimeSlotIndex, int StudentId);
private bool IsDirty()
{
if (_lastSavedState == null)
@@ -484,26 +468,7 @@
.ToArray();
// Create PartialTeam instances for teams with excluded students
// Aggregate exclusions across all time slots (since we don't know assignment yet)
var teamsForScheduling = _scheduledTeams.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 excludedStudents = team.Students.Where(s => excludedStudentIds.Contains(s.Id)).ToList();
if (excludedStudents.Count == 0)
return team;
// Create PartialTeam with excluded students
return team.CloneWithOmittedStudents(excludedStudents);
}).ToArray();
var teamsForScheduling = PartialTeam.CreatePartialTeamsFromExclusions(_scheduledTeams, _excludedStudents);
var teamScheduler = new TeamScheduler(teamsForScheduling, _parameters.TimeSlots, availableStudents);
_solution = teamScheduler.Solve();
@@ -541,7 +506,11 @@
// Post-process: extend teams to next consecutive time slot
if (_extendedTeams.Any())
{
ExtendTeamsInSolution(_solution, _extendedTeams, availableStudents);
TeamSchedulerPostProcessor.ExtendTeamsInSolution(
_solution,
_extendedTeams,
availableStudents,
GetTeamsWithoutExcludedStudents);
}
// Try recommendation strategies in priority order
@@ -568,6 +537,13 @@
await currentState.SaveToLocalStorage(LocalStorage);
_lastSavedState = currentState;
// Also save via state service for consistency
await StateService.SaveScheduledTeamsAsync(_scheduledTeams);
await StateService.SaveAbsentStudentsAsync(_absentStudents);
await StateService.SaveTimeSlotCountAsync(_parameters.TimeSlots);
await StateService.SaveExtendedTeamsAsync(_extendedTeams);
await StateService.SaveExcludedStudentsAsync(_excludedStudents);
await InvokeAsync(StateHasChanged); // let the UI know that the solution has been found
_isSolving = false;
@@ -579,91 +555,18 @@
_solutionData.ReloadServerData();
}
// TODO: Move team extension logic into Core.Calculation.TeamScheduler to handle extended teams
// as part of the constraint programming model rather than post-processing
private void ExtendTeamsInSolution(TeamSchedulerSolution solution, IEnumerable<Team> extendedTeams, Student[] allStudents)
{
if (solution.TimeSlots == null || !solution.TimeSlots.Any())
return;
var extendedTeamsList = extendedTeams.ToList();
if (!extendedTeamsList.Any())
return;
var extendedTeamIds = extendedTeamsList.Select(t => t.Id).ToHashSet();
// Find which time slot each extended team is in and extend both forward and backward
for (int slotIndex = 0; slotIndex < solution.TimeSlots.Length; slotIndex++)
{
var currentSlot = solution.TimeSlots[slotIndex];
var teamsToExtend = currentSlot.Teams.Where(t => extendedTeamIds.Contains(t.Id)).ToList();
if (!teamsToExtend.Any())
continue;
// Extend forward: add to next time slot (if exists)
if (slotIndex + 1 < solution.TimeSlots.Length)
{
var nextSlot = solution.TimeSlots[slotIndex + 1];
var nextSlotTeamsList = nextSlot.Teams.ToList();
var nextSlotTeamIds = nextSlotTeamsList.Select(t => t.Id).ToHashSet();
foreach (var team in teamsToExtend)
{
if (!nextSlotTeamIds.Contains(team.Id))
{
nextSlotTeamsList.Add(team);
nextSlotTeamIds.Add(team.Id);
}
}
nextSlot.Teams = nextSlotTeamsList.ToArray();
var nextSlotIndex = slotIndex + 1;
var nextSlotTeamsForOverlap = GetTeamsWithoutExcludedStudents(nextSlot.Teams, nextSlotIndex);
nextSlot.StudentOverlaps = TeamSchedulerSolution.GetStudentTeamOverlaps(nextSlotTeamsForOverlap);
// Use teams without excluded students so students excluded from all teams appear as unscheduled
nextSlot.UnscheduledStudents = TeamSchedulerSolution.GetStudentsNotInTimSlot(nextSlotTeamsForOverlap, allStudents);
}
// Extend backward: add to previous time slot (if exists)
if (slotIndex > 0)
{
var previousSlot = solution.TimeSlots[slotIndex - 1];
var previousSlotTeamsList = previousSlot.Teams.ToList();
var previousSlotTeamIds = previousSlotTeamsList.Select(t => t.Id).ToHashSet();
foreach (var team in teamsToExtend)
{
if (!previousSlotTeamIds.Contains(team.Id))
{
previousSlotTeamsList.Add(team);
previousSlotTeamIds.Add(team.Id);
}
}
previousSlot.Teams = previousSlotTeamsList.ToArray();
var previousSlotIndex = slotIndex - 1;
var previousSlotTeamsForOverlap = GetTeamsWithoutExcludedStudents(previousSlot.Teams, previousSlotIndex);
previousSlot.StudentOverlaps = TeamSchedulerSolution.GetStudentTeamOverlaps(previousSlotTeamsForOverlap);
// Use teams without excluded students so students excluded from all teams appear as unscheduled
previousSlot.UnscheduledStudents = TeamSchedulerSolution.GetStudentsNotInTimSlot(previousSlotTeamsForOverlap, allStudents);
}
}
}
async Task CopyToClipboard()
{
var sb = new StringBuilder();
foreach (var timeslot in _solution.TimeSlots)
{
AppendScheduledTeams(sb, timeslot);
AppendUnscheduledStudents(sb, timeslot);
sb.Append(Environment.NewLine);
}
try
{
await ClipboardService.WriteTextAsync(sb.ToString());
var text = ClipboardFormatService.FormatScheduleForClipboard(
_solution,
_teams,
_absentStudents,
_excludedStudents,
GetTimeSlotIndex);
await ClipboardService.WriteTextAsync(text);
}
catch
{
@@ -671,220 +574,86 @@
}
}
private void AppendScheduledTeams(StringBuilder sb, TeamScheduleTimeSlot timeslot)
private async Task OpenSaveHistoryDialog()
{
var timeSlotIndex = GetTimeSlotIndex(timeslot.Name);
foreach (var scheduledTeam in timeslot.Teams.OrderBy(e => e.ToString()))
var parameters = new DialogParameters
{
var teamName = scheduledTeam.ToString();
["ScheduledTeams"] = _scheduledTeams,
["AbsentStudents"] = _absentStudents,
["AllTeams"] = _teams,
["AllStudents"] = _students
};
if (scheduledTeam.Event.EventFormat is EventFormat.Individual)
var options = new DialogOptions
{
MaxWidth = MaxWidth.Medium,
FullWidth = true,
CloseButton = true
};
var dialog = await DialogService.ShowAsync<SaveMeetingHistoryDialog>("Save Meeting History", parameters, options);
var result = await dialog.Result;
// Note: Success message is already shown in the dialog, no need to show another here
}
private async Task LoadTeamsFromClipboard()
{
if (_isLoadingClipboard) return;
try
{
_isLoadingClipboard = true;
StateHasChanged();
var clipboardText = await ClipboardService.ReadTextAsync();
if (string.IsNullOrWhiteSpace(clipboardText))
{
sb.Append(teamName);
Snackbar.Add("Clipboard is empty", Severity.Warning);
return;
}
var matchedTeams = TeamClipboardMatcher.MatchTeamsFromClipboard(clipboardText, _teams);
if (!matchedTeams.Any())
{
Snackbar.Add("No matching teams found in clipboard text", Severity.Info);
return;
}
// Combine with existing scheduled teams, avoiding duplicates
var existingTeamIds = _scheduledTeams.Select(t => t.Id).ToHashSet();
var newTeams = matchedTeams.Where(t => !existingTeamIds.Contains(t.Id));
var updatedTeams = _scheduledTeams.Concat(newTeams).ToList();
OnScheduledTeamsChanged(updatedTeams);
var newCount = newTeams.Count();
var totalCount = matchedTeams.Count();
if (newCount == totalCount)
{
Snackbar.Add($"Selected {totalCount} team(s) from clipboard", Severity.Success);
}
else
{
var studentsList = FormatStudentList(scheduledTeam, timeslot, timeSlotIndex);
sb.Append($"{teamName} - {studentsList}");
Snackbar.Add($"Selected {newCount} new team(s) from clipboard ({totalCount - newCount} already selected)", Severity.Success);
}
sb.Append(Environment.NewLine);
}
catch (JSException ex)
{
Snackbar.Add("Unable to access clipboard. Please ensure clipboard permissions are granted.", Severity.Error);
}
catch (Exception ex)
{
Snackbar.Add($"Error loading teams from clipboard: {ex.Message}", Severity.Error);
}
finally
{
_isLoadingClipboard = false;
StateHasChanged();
}
}
private string FormatStudentList(Team team, TeamScheduleTimeSlot timeslot, int timeSlotIndex)
{
// Filter out excluded students for this team and time slot
var excludedStudentIds = _excludedStudents.Keys
.Where(k => k.teamId == team.Id && k.timeSlotIndex == timeSlotIndex && _excludedStudents[k])
.Select(k => k.studentId)
.ToHashSet();
var includedStudents = team.Students
.Where(s => !excludedStudentIds.Contains(s.Id))
.ToList();
// Create a temporary team with only included students for formatting
var teamForFormatting = new Team
{
Id = team.Id,
Event = team.Event,
Students = includedStudents,
Captain = team.Captain,
Identifier = team.Identifier
};
return TeamStudentNameFormatter.FormatStudentList(
teamForFormatting,
new TeamStudentNameFormatter.FormatOptions
{
Ordering = TeamStudentNameFormatter.OrderingStyle.CaptainFirst,
MarkOverlaps = true,
HasOverlaps = timeslot.StudentHasOverlaps,
MarkAbsent = true,
AbsentStudents = _absentStudents.ToList()
});
}
private string FormatStudentName(Student student, TeamScheduleTimeSlot timeslot)
{
// Find the team this student belongs to for formatting context
var team = _teams.FirstOrDefault(t => t.Students.Contains(student));
if (team == null)
{
// No team context, use StudentNameFormatter directly
return StudentNameFormatter.FormatStudentName(
student,
new StudentNameFormatter.FormatOptions
{
HasOverlap = timeslot.StudentHasOverlaps(student),
IsAbsent = _absentStudents.Contains(student)
});
}
return TeamStudentNameFormatter.FormatStudentName(
student,
team,
new TeamStudentNameFormatter.FormatOptions
{
MarkOverlaps = true,
HasOverlaps = timeslot.StudentHasOverlaps,
MarkAbsent = true,
AbsentStudents = _absentStudents.ToList()
});
}
private void AppendUnscheduledStudents(StringBuilder sb, TeamScheduleTimeSlot timeslot)
{
if (!timeslot.UnscheduledStudents.Any())
return;
sb.Append("--Unscheduled");
sb.Append(Environment.NewLine);
foreach (var student in timeslot.UnscheduledStudents)
{
var studentName = StudentNameFormatter.FormatStudentName(
student,
new StudentNameFormatter.FormatOptions
{
IsAbsent = _absentStudents.Contains(student)
});
var unassignedTeams = _solution.StudentUnassignedTeams(student);
var teamsList = string.Join(", ", unassignedTeams.Select(e => e.ToString()));
sb.Append($"{studentName} - {teamsList}");
sb.Append(Environment.NewLine);
}
}
private class MeetingScheduleState : IEquatable<MeetingScheduleState>
{
public HashSet<int> ScheduledTeamIds { get; set; } = [];
public HashSet<int> AbsentStudentIds { get; set; } = [];
public int TimeSlotCount { get; set; }
public HashSet<int> ExtendedTeamIds { get; set; } = [];
public HashSet<(int teamId, int timeSlotIndex, int studentId)> ExcludedStudents { get; set; } = [];
public bool Equals(MeetingScheduleState? other)
{
if (other == null) return false;
return ScheduledTeamIds.SetEquals(other.ScheduledTeamIds) &&
AbsentStudentIds.SetEquals(other.AbsentStudentIds) &&
TimeSlotCount == other.TimeSlotCount &&
ExtendedTeamIds.SetEquals(other.ExtendedTeamIds) &&
ExcludedStudents.SetEquals(other.ExcludedStudents);
}
public override bool Equals(object? obj) => Equals(obj as MeetingScheduleState);
public override int GetHashCode()
{
var hash = new HashCode();
hash.Add(ScheduledTeamIds.Count);
foreach (var id in ScheduledTeamIds.OrderBy(x => x))
hash.Add(id);
hash.Add(AbsentStudentIds.Count);
foreach (var id in AbsentStudentIds.OrderBy(x => x))
hash.Add(id);
hash.Add(TimeSlotCount);
hash.Add(ExtendedTeamIds.Count);
foreach (var id in ExtendedTeamIds.OrderBy(x => x))
hash.Add(id);
hash.Add(ExcludedStudents.Count);
foreach (var key in ExcludedStudents.OrderBy(x => x))
hash.Add(key);
return hash.ToHashCode();
}
public static MeetingScheduleState FromCurrent(
IEnumerable<Team> scheduledTeams,
IEnumerable<Student> absentStudents,
int timeSlotCount,
IEnumerable<Team> extendedTeams,
Dictionary<(int teamId, int timeSlotIndex, int studentId), bool> excludedStudents)
{
return new MeetingScheduleState
{
ScheduledTeamIds = scheduledTeams.Select(t => t.Id).ToHashSet(),
AbsentStudentIds = absentStudents.Select(s => s.Id).ToHashSet(),
TimeSlotCount = timeSlotCount,
ExtendedTeamIds = extendedTeams.Select(t => t.Id).ToHashSet(),
ExcludedStudents = excludedStudents.Keys
.Where(k => excludedStudents[k])
.ToHashSet()
};
}
public static async Task<MeetingScheduleState?> FromLocalStorage(
LocalStorageService localStorage,
Team[] allTeams,
Student[] allStudents)
{
// Load scheduled teams
var scheduledTeamIds = await localStorage.GetIntArrayAsync("MeetingSchedule_ScheduledTeams");
var absentStudentIds = await localStorage.GetIntArrayAsync("MeetingSchedule_AbsentStudents");
var timeSlotCount = await localStorage.GetIntAsync("MeetingSchedule_TimeSlotCount", defaultValue: 2);
var extendedTeamIds = await localStorage.GetIntArrayAsync("MeetingSchedule_ExtendedTeams");
var exclusions = await localStorage.GetJsonAsync<ExcludedStudent[]>("MeetingSchedule_ExcludedStudents");
// If no state exists, return null
if (scheduledTeamIds.Length == 0 && absentStudentIds.Length == 0 &&
timeSlotCount == 2 && extendedTeamIds.Length == 0 &&
(exclusions == null || exclusions.Length == 0))
{
return null;
}
var excludedStudentsSet = new HashSet<(int teamId, int timeSlotIndex, int studentId)>();
if (exclusions != null && exclusions.Length > 0)
{
foreach (var exclusion in exclusions)
{
excludedStudentsSet.Add((exclusion.TeamId, exclusion.TimeSlotIndex, exclusion.StudentId));
}
}
return new MeetingScheduleState
{
ScheduledTeamIds = scheduledTeamIds.ToHashSet(),
AbsentStudentIds = absentStudentIds.ToHashSet(),
TimeSlotCount = timeSlotCount > 0 ? timeSlotCount : 2,
ExtendedTeamIds = extendedTeamIds.ToHashSet(),
ExcludedStudents = excludedStudentsSet
};
}
public async Task SaveToLocalStorage(LocalStorageService localStorage)
{
await localStorage.SetIntArrayAsync("MeetingSchedule_ScheduledTeams", ScheduledTeamIds.ToArray());
await localStorage.SetIntArrayAsync("MeetingSchedule_AbsentStudents", AbsentStudentIds.ToArray());
await localStorage.SetIntAsync("MeetingSchedule_TimeSlotCount", TimeSlotCount);
await localStorage.SetIntArrayAsync("MeetingSchedule_ExtendedTeams", ExtendedTeamIds.ToArray());
var exclusions = ExcludedStudents.Select(e => new ExcludedStudent(e.teamId, e.timeSlotIndex, e.studentId)).ToArray();
await localStorage.SetJsonAsync("MeetingSchedule_ExcludedStudents", exclusions);
}
}
}
@@ -0,0 +1,502 @@
@namespace WebApp.Components.Features.MeetingSchedule
@using Core.Entities
@using Core.Services
@using Core.Utility
@using WebApp.Services
@using WebApp.Components.Shared.Components
@using WebApp.Models
@inject ITeamMeetingHistoryService TeamMeetingHistoryService
@inject INotesService NotesService
@inject INoteNamingService NoteNamingService
@inject ISnackbar Snackbar
@inject IDialogService DialogService
@inject IMeetingScheduleDataService DataService
@inject IMeetingScheduleStateService StateService
@inject NavigationManager NavigationManager
@implements IAsyncDisposable
<MudDialog>
<DialogContent>
@if (_isLoading)
{
<MudProgressLinear Color="Color.Primary" Indeterminate="true" Class="my-4" />
}
else if (_meetingHistory == null)
{
<MudAlert Severity="Severity.Error">Meeting history not found.</MudAlert>
}
else
{
<MudStack Spacing="3">
@* Navigation Header *@
<MudStack Row="true" Justify="Justify.SpaceBetween" AlignItems="AlignItems.Center" Spacing="2">
<MudTooltip Text="@(_previousMeetingHistory != null ? $"Previous: {_previousMeetingHistory.MeetingDate:MM/dd/yyyy}" : "No previous meeting")">
<span>
<MudIconButton Icon="@Icons.Material.Filled.ChevronLeft"
OnClick="NavigateToPrevious"
Disabled="@(_previousMeetingHistory == null || IsActionDisabled)"
Color="Color.Primary"
Size="Size.Medium" />
</span>
</MudTooltip>
<MudText Typo="Typo.h6" Class="flex-grow-1" Style="text-align: center;">@_meetingHistory.MeetingDate.ToString("MM/dd/yyyy")</MudText>
<MudTooltip Text="@(_nextMeetingHistory != null ? $"Next: {_nextMeetingHistory.MeetingDate:MM/dd/yyyy}" : "No next meeting")">
<span>
<MudIconButton Icon="@Icons.Material.Filled.ChevronRight"
OnClick="NavigateToNext"
Disabled="@(_nextMeetingHistory == null || IsActionDisabled)"
Color="Color.Primary"
Size="Size.Medium" />
</span>
</MudTooltip>
</MudStack>
<MudText Typo="Typo.subtitle1">Teams That Met (@_meetingHistory.Teams.Count)</MudText>
<MudPaper Elevation="1" Class="pa-2">
<MudStack Row="true" Spacing="1" Wrap="Wrap.Wrap">
@foreach (var team in _meetingHistory.Teams.OrderByEventFormatFirst().ThenBy(e => e.ToString()))
{
<MudChip T="string" Size="Size.Small" Color="Color.Default" Variant="@AppIcons.TeamChipVariant()" Class="mx-1 my-1">@team.ToString()</MudChip>
}
</MudStack>
</MudPaper>
<MudDivider />
<MudText Typo="Typo.subtitle1">Students (@GetAllStudentsFromTeams().Count)</MudText>
<MudPaper Elevation="1" Class="pa-2">
<MudStack Row="true" Spacing="1" Wrap="Wrap.Wrap">
@{
var presentStudentIds = _meetingHistory.Students.Select(s => s.Id).ToHashSet();
var allStudents = GetAllStudentsFromTeams().OrderBy(s => s.FirstName);
}
@foreach (var student in allStudents)
{
var isPresent = presentStudentIds.Contains(student.Id);
<MudChip T="string"
Size="Size.Small"
Color="Color.Default"
Variant="@AppIcons.StudentChipVariant()"
Class="mx-1 my-1"
Style="@(!isPresent ? "opacity: 0.5;" : "")">
@student.FirstNameLastName
</MudChip>
}
</MudStack>
</MudPaper>
@if (_meetingNote != null)
{
<MudDivider />
<MudText Typo="Typo.subtitle1">Meeting Notes</MudText>
<MudPaper Elevation="1" Class="pa-3">
<MudText Typo="Typo.body2"><strong>@_meetingNote.Title</strong></MudText>
@if (!string.IsNullOrWhiteSpace(_meetingNote.Content))
{
<MudText Typo="Typo.body2" Class="mt-2">
@((MarkupString)MarkdownHelper.ToHtml(_meetingNote.Content))
</MudText>
}
<MudButton Variant="Variant.Text"
Size="Size.Small"
Color="Color.Primary"
StartIcon="@Icons.Material.Filled.Edit"
OnClick="ViewNote"
Class="mt-2">
Edit Note
</MudButton>
</MudPaper>
}
</MudStack>
}
</DialogContent>
<DialogActions>
@if (_meetingHistory != null)
{
<MudButton Variant="Variant.Text"
Color="Color.Error"
OnClick="ConfirmDelete"
Disabled="@IsActionDisabled">
Delete
</MudButton>
<MudSpacer />
<MudButton Variant="Variant.Text"
Color="Color.Secondary"
OnClick="LoadIntoPlanner"
Disabled="@IsActionDisabled"
StartIcon="@Icons.Material.Filled.Upload">
Load into Planner
</MudButton>
<MudButton Variant="Variant.Text"
Color="Color.Primary"
OnClick="OpenEditDialog"
Disabled="@IsActionDisabled"
StartIcon="@Icons.Material.Filled.Edit">
Edit
</MudButton>
<MudButton OnClick="Close" Disabled="@IsActionDisabled">Close</MudButton>
}
else
{
<MudSpacer />
<MudButton OnClick="Close">Close</MudButton>
}
</DialogActions>
</MudDialog>
@code {
[CascadingParameter]
IMudDialogInstance MudDialog { get; set; } = null!;
[Parameter]
public int MeetingHistoryId { get; set; }
private TeamMeetingHistory? _meetingHistory;
private Note? _meetingNote;
private bool _isLoading = true;
private bool _isDeleting = false;
private Team[] _allTeams = [];
private Student[] _allStudents = [];
private CancellationTokenSource? _cancellationTokenSource;
private bool _isDisposed = false;
private bool IsActionDisabled => _isLoading || _isDeleting;
private TeamMeetingHistory? _previousMeetingHistory;
private TeamMeetingHistory? _nextMeetingHistory;
protected override void OnInitialized()
{
_cancellationTokenSource = new CancellationTokenSource();
}
protected override async Task OnInitializedAsync()
{
// Load all teams and students for the edit dialog
_allTeams = await DataService.LoadTeamsAsync();
_allStudents = await DataService.LoadStudentsAsync();
await LoadMeetingHistory();
}
private async Task LoadMeetingHistory()
{
if (_isDisposed) return;
try
{
_meetingHistory = await TeamMeetingHistoryService.GetMeetingHistoryAsync(MeetingHistoryId);
// Load note by title if meeting history exists
if (_meetingHistory != null)
{
_meetingNote = await TeamMeetingHistoryService.GetMeetingNoteAsync(_meetingHistory.MeetingDate);
// Load all meeting histories to find previous/next
await LoadNavigationMeetings();
}
}
catch (TaskCanceledException)
{
// Component was disposed, ignore
}
catch (JSDisconnectedException)
{
// JS connection lost, ignore
}
catch (Exception ex)
{
if (!_isDisposed)
{
Snackbar.Add($"Error loading meeting history: {ex.Message}", Severity.Error);
}
}
finally
{
if (!_isDisposed)
{
_isLoading = false;
StateHasChanged();
}
}
}
private async Task LoadNavigationMeetings()
{
if (_isDisposed || _meetingHistory == null) return;
try
{
// Get all meeting histories ordered by date
var allMeetings = (await TeamMeetingHistoryService.GetMeetingHistoriesAsync())
.OrderBy(m => m.MeetingDate)
.ThenBy(m => m.Id)
.ToList();
var currentIndex = allMeetings.FindIndex(m => m.Id == _meetingHistory.Id);
if (currentIndex >= 0)
{
_previousMeetingHistory = currentIndex > 0 ? allMeetings[currentIndex - 1] : null;
_nextMeetingHistory = currentIndex < allMeetings.Count - 1 ? allMeetings[currentIndex + 1] : null;
}
else
{
_previousMeetingHistory = null;
_nextMeetingHistory = null;
}
}
catch (TaskCanceledException)
{
// Component was disposed, ignore
}
catch (JSDisconnectedException)
{
// JS connection lost, ignore
}
catch (Exception ex)
{
if (!_isDisposed)
{
// Log error but don't show snackbar - navigation is not critical
System.Diagnostics.Debug.WriteLine($"Error loading navigation meetings: {ex.Message}");
}
}
}
private async Task NavigateToPrevious()
{
if (_previousMeetingHistory == null || _isDisposed) return;
// Close current dialog and open new one with previous meeting ID
var parameters = new DialogParameters
{
["MeetingHistoryId"] = _previousMeetingHistory.Id
};
var options = new DialogOptions
{
MaxWidth = MaxWidth.Medium,
FullWidth = true,
CloseButton = true
};
MudDialog.Close();
await DialogService.ShowAsync<MeetingHistoryDetailDialog>("Meeting History", parameters, options);
}
private async Task NavigateToNext()
{
if (_nextMeetingHistory == null || _isDisposed) return;
// Close current dialog and open new one with next meeting ID
var parameters = new DialogParameters
{
["MeetingHistoryId"] = _nextMeetingHistory.Id
};
var options = new DialogOptions
{
MaxWidth = MaxWidth.Medium,
FullWidth = true,
CloseButton = true
};
MudDialog.Close();
await DialogService.ShowAsync<MeetingHistoryDetailDialog>("Meeting History", parameters, options);
}
private async Task ConfirmDelete()
{
if (_isDisposed || _isDeleting || _meetingHistory == null) return;
var result = await DialogService.ShowMessageBox(
"Confirm Delete",
$"Are you sure you want to delete the meeting history for {_meetingHistory.MeetingDate:MM/dd/yyyy}? This action cannot be undone.",
yesText: "Delete",
cancelText: "Cancel");
if (result == true)
{
await DeleteMeetingHistory();
}
}
private async Task DeleteMeetingHistory()
{
if (_isDisposed || _isDeleting || _meetingHistory == null) return;
try
{
_isDeleting = true;
StateHasChanged();
await TeamMeetingHistoryService.DeleteMeetingHistoryAsync(MeetingHistoryId);
if (!_isDisposed)
{
Snackbar.Add("Meeting history deleted successfully", Severity.Success);
MudDialog.Close(DialogResult.Ok(true));
}
}
catch (TaskCanceledException)
{
// Component was disposed, ignore
}
catch (JSDisconnectedException)
{
// JS connection lost, ignore
}
catch (Exception ex)
{
if (!_isDisposed)
{
Snackbar.Add($"Error deleting meeting history: {ex.Message}", Severity.Error);
_isDeleting = false;
StateHasChanged();
}
}
}
private async Task ViewNote()
{
if (_meetingNote == null) return;
var parameters = new DialogParameters
{
["NoteId"] = _meetingNote.Id
};
var options = new DialogOptions
{
MaxWidth = MaxWidth.Medium,
FullWidth = true,
CloseButton = true
};
var dialog = await DialogService.ShowAsync<NoteViewDialog>("Meeting Notes", parameters, options);
await dialog.Result;
// Refresh meeting history to get updated note
await LoadMeetingHistory();
}
private async Task OpenEditDialog()
{
if (_meetingHistory == null || _isDisposed) return;
var parameters = new DialogParameters
{
["MeetingHistoryId"] = _meetingHistory.Id,
["AllTeams"] = _allTeams,
["AllStudents"] = _allStudents,
["ScheduledTeams"] = new List<Team>(), // Not used when editing
["AbsentStudents"] = new List<Student>() // Not used when editing
};
var options = new DialogOptions
{
MaxWidth = MaxWidth.Medium,
FullWidth = true,
CloseButton = true
};
var dialog = await DialogService.ShowAsync<SaveMeetingHistoryDialog>("Edit Meeting History", parameters, options);
var result = await dialog.Result;
// Refresh meeting history if dialog was saved
if (!result.Canceled && !_isDisposed)
{
await LoadMeetingHistory();
}
}
private List<Student> GetAllStudentsFromTeams()
{
if (_meetingHistory == null)
return [];
var allStudents = new List<Student>();
var studentIds = new HashSet<int>();
foreach (var team in _meetingHistory.Teams)
{
foreach (var student in team.Students)
{
if (!studentIds.Contains(student.Id))
{
studentIds.Add(student.Id);
allStudents.Add(student);
}
}
}
return allStudents;
}
private async Task LoadIntoPlanner()
{
if (_isDisposed || _meetingHistory == null) return;
try
{
// Get all teams and students from database
var allTeams = await DataService.LoadTeamsAsync();
var allStudents = await DataService.LoadStudentsAsync();
// Match teams from history to all teams by ID for reference equality
var historyTeamIds = _meetingHistory.Teams.Select(t => t.Id).ToHashSet();
var scheduledTeams = allTeams.Where(t => historyTeamIds.Contains(t.Id));
// Calculate absent students (all students not in the meeting history's student list)
var presentStudentIds = _meetingHistory.Students.Select(s => s.Id).ToHashSet();
var absentStudents = allStudents.Where(s => !presentStudentIds.Contains(s.Id));
// Save state to localStorage
await StateService.SaveScheduledTeamsAsync(scheduledTeams);
await StateService.SaveAbsentStudentsAsync(absentStudents);
// Clear extended teams and excluded students when loading from history
await StateService.SaveExtendedTeamsAsync([]);
await StateService.SaveExcludedStudentsAsync(new Dictionary<(int teamId, int timeSlotIndex, int studentId), bool>());
// Close dialog and navigate to planner
MudDialog.Close();
NavigationManager.NavigateTo("/meeting-schedule");
if (!_isDisposed)
{
Snackbar.Add($"Loaded meeting from {_meetingHistory.MeetingDate:MM/dd/yyyy} into planner", Severity.Success);
}
}
catch (TaskCanceledException)
{
// Component was disposed, ignore
}
catch (JSDisconnectedException)
{
// JS connection lost, ignore
}
catch (Exception ex)
{
if (!_isDisposed)
{
Snackbar.Add($"Error loading meeting into planner: {ex.Message}", Severity.Error);
}
}
}
private void Close()
{
if (_isDisposed) return;
MudDialog.Close();
}
public async ValueTask DisposeAsync()
{
if (!_isDisposed)
{
_isDisposed = true;
_cancellationTokenSource?.Cancel();
_cancellationTokenSource?.Dispose();
_cancellationTokenSource = null;
}
await ValueTask.CompletedTask;
}
}
@@ -0,0 +1,418 @@
@namespace WebApp.Components.Features.MeetingSchedule
@using Core.Entities
@using Core.Calculation
@using Core.Services
@using WebApp.Services
@using WebApp.Components.Shared.Components
@using WebApp.Components.Features.Teams.Components
@using WebApp.Components.Features.Students.Components
@using WebApp.Models
@inject ITeamMeetingHistoryService TeamMeetingHistoryService
@inject INotesService NotesService
@inject INoteNamingService NoteNamingService
@inject ISnackbar Snackbar
@inject IDialogService DialogService
@implements IAsyncDisposable
<MudDialog>
<DialogContent>
@if (_isLoading)
{
<MudProgressLinear Color="Color.Primary" Indeterminate="true" Class="my-4" />
}
else
{
<MudStack Spacing="3">
<MudText Typo="Typo.h6">@(_isEditMode ? "Edit Meeting History" : "Save Meeting History")</MudText>
<MudDatePicker Label="Meeting Date"
Date="_meetingDate"
DateChanged="OnMeetingDateChanged"
Variant="Variant.Outlined"
Disabled="@_isEditMode" />
<MudDivider />
<MudPaper Elevation="1" Class="pa-2" Style="max-height: 300px; overflow-y: auto;">
<TeamToggleSelector Teams="@AllTeams"
SelectedTeams="_selectedTeams"
SelectedTeamsChanged="OnTeamsChanged"
Title="Teams That Met"
ShowEventAttributes="false" />
</MudPaper>
<MudDivider />
<MudPaper Elevation="1" Class="pa-2" Style="max-height: 300px; overflow-y: auto;">
<StudentToggleSelector Students="@AllStudents"
SelectedStudents="_selectedStudents"
SelectedStudentsChanged="OnStudentsChanged"
Title="Students Present"
ShowFullName="true" />
</MudPaper>
<MudDivider />
<MudExpansionPanels MultiExpansion="false">
<MudExpansionPanel Text="Meeting Notes (Optional)">
<MudStack Spacing="2">
<MudTextField T="string"
Label="Note Title"
@bind-Value="_noteTitle"
Variant="Variant.Outlined"
ReadOnly="true"
HelperText="Title is automatically generated based on meeting date" />
<MudTextField T="string"
Label="Note Content"
@bind-Value="_noteContent"
Variant="Variant.Outlined"
Lines="5"
Placeholder="Enter meeting notes..."
HelperText="Optional markdown content for meeting notes" />
</MudStack>
</MudExpansionPanel>
</MudExpansionPanels>
</MudStack>
}
</DialogContent>
<DialogActions>
<MudButton OnClick="Cancel" Disabled="@_isSaving">Cancel</MudButton>
<MudButton Color="Color.Primary" Variant="Variant.Filled" OnClick="Save" Disabled="@IsSaveDisabled">
@if (_isSaving)
{
<MudProgressCircular Size="Size.Small" Indeterminate="true" Class="mr-2" />
<span>Saving...</span>
}
else
{
<span>Save</span>
}
</MudButton>
</DialogActions>
</MudDialog>
@code {
[CascadingParameter]
IMudDialogInstance MudDialog { get; set; } = null!;
[Parameter]
public IEnumerable<Team> ScheduledTeams { get; set; } = [];
[Parameter]
public IEnumerable<Student> AbsentStudents { get; set; } = [];
[Parameter]
public IEnumerable<Team> AllTeams { get; set; } = [];
[Parameter]
public IEnumerable<Student> AllStudents { get; set; } = [];
[Parameter]
public int? MeetingHistoryId { get; set; }
private DateTime? _meetingDate = DateTime.Today;
private IEnumerable<Team> _selectedTeams = [];
private IEnumerable<Student> _selectedStudents = [];
private string _noteTitle = "";
private string _noteContent = "";
private bool _isLoading = true;
private bool _isSaving = false;
private bool _isEditMode = false;
private CancellationTokenSource? _cancellationTokenSource;
private bool _isDisposed = false;
protected override void OnInitialized()
{
_cancellationTokenSource = new CancellationTokenSource();
}
protected override async Task OnInitializedAsync()
{
await LoadInitialData();
}
private async Task LoadInitialData()
{
if (_isDisposed) return;
try
{
// If editing, load existing meeting history
if (MeetingHistoryId.HasValue)
{
_isEditMode = true;
var existingHistory = await TeamMeetingHistoryService.GetMeetingHistoryAsync(MeetingHistoryId.Value);
if (existingHistory != null)
{
_meetingDate = existingHistory.MeetingDate;
// Match teams by ID to ensure reference equality with MudToggleGroup
var selectedTeamIds = existingHistory.Teams.Select(t => t.Id).ToHashSet();
_selectedTeams = AllTeams.Where(t => selectedTeamIds.Contains(t.Id));
// Match students by ID to ensure reference equality with MudToggleGroup
var selectedStudentIds = existingHistory.Students.Select(s => s.Id).ToHashSet();
_selectedStudents = AllStudents.Where(s => selectedStudentIds.Contains(s.Id));
// Load existing note if available
var existingNote = await TeamMeetingHistoryService.GetMeetingNoteAsync(existingHistory.MeetingDate);
if (existingNote != null)
{
_noteContent = existingNote.Content ?? "";
}
}
}
else
{
// Initialize selected teams from scheduled teams
_selectedTeams = ScheduledTeams;
// Initialize selected students (all students except absent ones)
var absentStudentIds = AbsentStudents.Select(s => s.Id).ToHashSet();
_selectedStudents = AllStudents.Where(s => !absentStudentIds.Contains(s.Id));
}
// Generate default note title if meeting date is set
if (_meetingDate.HasValue)
{
_noteTitle = NoteNamingService.GetMeetingNoteTitle(_meetingDate.Value);
}
}
catch (TaskCanceledException)
{
// Component was disposed, ignore
}
catch (JSDisconnectedException)
{
// JS connection lost, ignore
}
catch (Exception ex)
{
if (!_isDisposed)
{
Snackbar.Add($"Error loading data: {ex.Message}", Severity.Error);
}
}
finally
{
if (!_isDisposed)
{
_isLoading = false;
StateHasChanged();
}
}
}
private bool IsSaveDisabled => _isSaving || _isLoading;
protected override async Task OnParametersSetAsync()
{
if (_meetingDate.HasValue && string.IsNullOrEmpty(_noteTitle))
{
_noteTitle = NoteNamingService.GetMeetingNoteTitle(_meetingDate.Value);
}
await base.OnParametersSetAsync();
}
private async Task OnMeetingDateChanged(DateTime? date)
{
_meetingDate = date;
if (date.HasValue)
{
_noteTitle = NoteNamingService.GetMeetingNoteTitle(date.Value);
}
await InvokeAsync(StateHasChanged);
}
private void OnTeamsChanged(IEnumerable<Team> teams)
{
_selectedTeams = teams;
StateHasChanged();
}
private void OnStudentsChanged(IEnumerable<Student> students)
{
_selectedStudents = students;
StateHasChanged();
}
private async Task Save()
{
if (_isDisposed || _isSaving) return;
if (!_meetingDate.HasValue)
{
Snackbar.Add("Please select a meeting date", Severity.Warning);
return;
}
// Check if a meeting history already exists for this date (only when creating new, not editing)
if (!_isEditMode)
{
var dateOnly = _meetingDate.Value.Date;
// GetMeetingHistoriesAsync: startDate >= date, endDate < (endDate.Date + 1 day)
// To get meetings for a single day, pass dateOnly as startDate and dateOnly as endDate
// This becomes: MeetingDate >= dateOnly AND MeetingDate < (dateOnly + 1 day) = just that day
var existingMeetings = await TeamMeetingHistoryService.GetMeetingHistoriesAsync(dateOnly, dateOnly);
if (existingMeetings.Any())
{
// Show confirmation dialog
var confirmResult = await DialogService.ShowMessageBox(
"Overwrite Meeting?",
"A meeting already exists for this date. Overwrite it?",
yesText: "Overwrite",
cancelText: "Cancel");
if (confirmResult != true)
{
return; // User cancelled
}
// User confirmed, switch to edit mode
var existingMeeting = existingMeetings.First();
_isEditMode = true;
MeetingHistoryId = existingMeeting.Id;
// Load existing meeting data
var existingHistory = await TeamMeetingHistoryService.GetMeetingHistoryAsync(existingMeeting.Id);
if (existingHistory != null)
{
// Match teams by ID to ensure reference equality with MudToggleGroup
var selectedTeamIds = existingHistory.Teams.Select(t => t.Id).ToHashSet();
_selectedTeams = AllTeams.Where(t => selectedTeamIds.Contains(t.Id));
// Match students by ID to ensure reference equality with MudToggleGroup
var selectedStudentIds = existingHistory.Students.Select(s => s.Id).ToHashSet();
_selectedStudents = AllStudents.Where(s => selectedStudentIds.Contains(s.Id));
// Load existing note if available
var existingNote = await TeamMeetingHistoryService.GetMeetingNoteAsync(existingHistory.MeetingDate);
if (existingNote != null)
{
_noteContent = existingNote.Content ?? "";
}
}
}
}
try
{
_isSaving = true;
StateHasChanged();
// Create or update note if note content is provided
Note? note = null;
if (!string.IsNullOrWhiteSpace(_noteContent))
{
// Use the naming service to get the meeting note title
var noteTitle = NoteNamingService.GetMeetingNoteTitle(_meetingDate.Value);
// Check if note already exists
var existingNote = await NotesService.GetNotesAsync(includeDeleted: false);
note = existingNote.FirstOrDefault(n => n.Title == noteTitle);
if (note != null)
{
// Update existing note
note.Content = _noteContent;
note = await NotesService.UpdateNoteAsync(note);
}
else
{
// Create new note
note = new Note
{
Title = noteTitle,
Content = _noteContent
};
note = await NotesService.CreateNoteAsync(note);
}
}
// Create or update meeting history
TeamMeetingHistory meetingHistory;
if (_isEditMode && MeetingHistoryId.HasValue)
{
// Update existing meeting history
var existingHistory = await TeamMeetingHistoryService.GetMeetingHistoryAsync(MeetingHistoryId.Value);
if (existingHistory == null)
{
Snackbar.Add("Meeting history not found", Severity.Error);
_isSaving = false;
StateHasChanged();
return;
}
meetingHistory = existingHistory;
meetingHistory.MeetingDate = _meetingDate.Value;
meetingHistory.Teams = _selectedTeams.ToList();
meetingHistory.Students = _selectedStudents.ToList();
await TeamMeetingHistoryService.UpdateMeetingHistoryAsync(meetingHistory);
if (!_isDisposed)
{
Snackbar.Add($"Meeting history updated for {_meetingDate.Value:MM/dd/yyyy}", Severity.Success);
}
}
else
{
// Create new meeting history
meetingHistory = new TeamMeetingHistory
{
MeetingDate = _meetingDate.Value,
Teams = _selectedTeams.ToList(),
Students = _selectedStudents.ToList()
};
await TeamMeetingHistoryService.CreateMeetingHistoryAsync(meetingHistory);
if (!_isDisposed)
{
Snackbar.Add($"Meeting history saved for {_meetingDate.Value:MM/dd/yyyy}", Severity.Success);
}
}
if (!_isDisposed)
{
MudDialog.Close(DialogResult.Ok(true));
}
}
catch (TaskCanceledException)
{
// Component was disposed, ignore
}
catch (JSDisconnectedException)
{
// JS connection lost, ignore
}
catch (Exception ex)
{
if (!_isDisposed)
{
Snackbar.Add($"Error saving meeting history: {ex.Message}", Severity.Error);
_isSaving = false;
StateHasChanged();
}
}
}
private void Cancel()
{
if (_isDisposed) return;
MudDialog.Cancel();
}
public async ValueTask DisposeAsync()
{
if (!_isDisposed)
{
_isDisposed = true;
_cancellationTokenSource?.Cancel();
_cancellationTokenSource?.Dispose();
_cancellationTokenSource = null;
}
await ValueTask.CompletedTask;
}
}
@@ -1,4 +1,4 @@
@page "/teams/printout"
@page "/teams/printout"
@attribute [Authorize]
@using Microsoft.EntityFrameworkCore
@using WebApp.Models
@@ -110,7 +110,7 @@ else
<RowTemplate>
<MudTd>@context.Name</MudTd>
<MudTd>@context.Teams.Sum(e => e.Event.LevelOfEffort)</MudTd>
<MudTd>@context.Teams.Sum(e => e.Event?.LevelOfEffort ?? 0)</MudTd>
@{
var teams = context.Teams
.OrderBy(e =>
@@ -169,7 +169,7 @@ else
<MudTd>@context.Name</MudTd>
<MudTd>@AppIcons.GetOrdinal(context.Grade), @context.TsaYear</MudTd>
<MudTd>@context.Teams.Sum(e => e.Event.LevelOfEffort)
<MudTd>@context.Teams.Sum(e => e.Event?.LevelOfEffort ?? 0)
@if (!context.Teams.Select(e => e.Event).Any(re => re.OnSiteActivity))
{
<span>No On-Site Activity</span>
+1 -1
View File
@@ -123,7 +123,7 @@ else
</MudPaper>
<MudGrid>
<DashboardCard Icon="@AppIcons.Scheduler"
Title="Meeting Schedule"
Title="Meeting Schedule Planner"
Caption="Optimize meeting times"
NavigateUrl="/meeting-schedule"/>
+4 -2
View File
@@ -1,8 +1,10 @@
@using Core.Entities
@using Core.Services
@using WebApp.Services
@using PSC.Blazor.Components.MarkdownEditor
@using MudBlazor
@inject INotesService NotesService
@inject INoteNamingService NoteNamingService
@inject ISnackbar Snackbar
@inject IDialogService DialogService
@inject MarkdownTablePasteService MarkdownTablePasteService
@@ -45,7 +47,7 @@
private Note _note = null!;
private bool _pasteMarkdownInitialized = false;
private bool IsPageNote => Note?.Title?.StartsWith("@") ?? false;
private bool IsPageNote => Note?.Title != null && NoteNamingService.IsPageNote(Note.Title);
protected override void OnInitialized()
{
@@ -99,6 +101,6 @@
private void Cancel()
{
MudDialog.Cancel();
MudDialog.Close(DialogResult.Cancel());
}
}
+4 -2
View File
@@ -2,9 +2,11 @@
@attribute [Authorize]
@implements IAsyncDisposable
@using Core.Entities
@using Core.Services
@using WebApp.Services
@using WebApp.Components.Shared.Components
@inject INotesService NotesService
@inject INoteNamingService NoteNamingService
@inject IDialogService DialogService
@inject ISnackbar Snackbar
@inject NavigationManager NavigationManager
@@ -67,7 +69,7 @@
@GetNoteHeaderText(note, isExpanded)
</span>
</MudText>
@if (!note.Title.StartsWith("@") && !note.IsDeleted && !isExpanded)
@if (!NoteNamingService.IsPageNote(note.Title) && !note.IsDeleted && !isExpanded)
{
<MudButton StartIcon="@(note.IsPinned ? Icons.Material.Filled.PushPin : Icons.Material.Outlined.PushPin)"
OnClick="() => TogglePin(note)"
@@ -386,7 +388,7 @@
return false;
// Can't pin page notes
if (note.Title.StartsWith("@"))
if (NoteNamingService.IsPageNote(note.Title))
return true;
// Can't pin deleted notes
@@ -0,0 +1,54 @@
@namespace WebApp.Components.Shared.Components
<MudPaper Elevation="0" Class="pa-1" Style="border: 1px solid var(--mud-palette-lines-default); border-radius: var(--mud-default-borderradius);">
<MudStack Row="true" AlignItems="AlignItems.Center" Spacing="2">
<MudTooltip Text="@AddTooltip">
<MudIconButton Icon="@Icons.Material.Filled.Add"
Variant="Variant.Outlined"
Color="Color.Primary"
OnClick="HandleAdd"
Size="Size.Small" />
</MudTooltip>
<MudText Typo="Typo.body2" Style="flex: 1; text-align: center;">@Label</MudText>
<MudTooltip Text="@RemoveTooltip">
<MudIconButton Icon="@Icons.Material.Filled.Remove"
Variant="Variant.Outlined"
Color="Color.Error"
OnClick="HandleRemove"
Size="Size.Small" />
</MudTooltip>
</MudStack>
</MudPaper>
@code {
[Parameter]
public required string Label { get; set; }
[Parameter]
public EventCallback OnAdd { get; set; }
[Parameter]
public EventCallback OnRemove { get; set; }
[Parameter]
public string? AddTooltip { get; set; }
[Parameter]
public string? RemoveTooltip { get; set; }
private async Task HandleAdd()
{
if (OnAdd.HasDelegate)
{
await OnAdd.InvokeAsync();
}
}
private async Task HandleRemove()
{
if (OnRemove.HasDelegate)
{
await OnRemove.InvokeAsync();
}
}
}
@@ -6,9 +6,7 @@
Class="@WrapperClass"
@onmouseenter="@(() => _isHovered = true)"
@onmouseleave="@(() => _isHovered = false)"
@ontouchstart="@(() => _isTouched = true)"
@ontouchend="@(() => { /* Prevent mouse events on touch */ })"
@onclick="@HandleClick">
@ontouchstart="@HandleTouchStart">
<MudChip T="string"
Size="@Size"
Color="@Color"
@@ -69,12 +67,9 @@
private bool _isHovered = false;
private bool _isTouched = false;
private void HandleClick(MouseEventArgs e)
private void HandleTouchStart(TouchEventArgs e)
{
// On touch devices, toggle controls on tap (for devices with both touch and mouse)
if (_isTouched)
{
_isTouched = !_isTouched;
}
_isTouched = !_isTouched;
StateHasChanged();
}
}
@@ -3,18 +3,45 @@
@inject IDialogService DialogService
@implements IAsyncDisposable
<MudButton StartIcon="@IconValue"
OnClick="OpenDialog"
Variant="@Variant"
Size="@Size"
Color="@ButtonColor"
Tooltip="@TooltipText"
Class="@MarkdownHelper.GetNoteColorClass(_noteId)">
@if (!string.IsNullOrEmpty(ButtonText))
{
@ButtonText
}
</MudButton>
<div @ref="_anchorElement"
@onmouseenter="@(() => { if (_hasContent) _popoverOpen = true; })"
@onmouseleave="@(() => _popoverOpen = false)"
style="display: inline-block;">
<MudButton StartIcon="@IconValue"
OnClick="OpenDialog"
Variant="@Variant"
Size="@Size"
Color="@ButtonColor"
Tooltip="@TooltipText"
Class="@MarkdownHelper.GetNoteColorClass(_noteId)">
@if (!string.IsNullOrEmpty(ButtonText))
{
@ButtonText
}
</MudButton>
</div>
<MudPopover @bind-Open="_popoverOpen"
AnchorOrigin="Origin.BottomCenter"
TransformOrigin="Origin.TopCenter"
Elevation="8"
Anchor="@_anchorElement">
<ChildContent>
@if (_hasContent && !string.IsNullOrWhiteSpace(_noteContent))
{
<MudPaper Elevation="0"
Class="pa-3"
Style="max-width: 500px; max-height: 400px; overflow-y: auto;"
@onmouseenter="@(() => _popoverOpen = true)"
@onmouseleave="@(() => _popoverOpen = false)">
<MudText Typo="Typo.subtitle1" Class="mb-2">@PageIdentifier</MudText>
<MudDivider Class="my-2" />
<div class="markdown-content" style="max-height: 350px; overflow-y: auto;">
@((MarkupString)MarkdownHelper.ToHtml(_noteContent))
</div>
</MudPaper>
}
</ChildContent>
</MudPopover>
@code {
[Parameter]
@@ -39,6 +66,9 @@
private string TooltipText => Tooltip ?? $"Page notes for {PageIdentifier}";
private bool _hasContent = false;
private int _noteId = 0;
private string _noteContent = string.Empty;
private bool _popoverOpen = false;
private ElementReference _anchorElement;
private Color ButtonColor => _hasContent ? Color.Success : (Variant == Variant.Filled ? Color.Primary : Color.Default);
private CancellationTokenSource? _cancellationTokenSource;
private bool _isDisposed = false;
@@ -62,6 +92,7 @@
var note = await NotesService.GetPageNoteAsync(PageIdentifier);
_hasContent = note != null && !string.IsNullOrWhiteSpace(note.Content);
_noteId = note?.Id ?? 0;
_noteContent = note?.Content ?? string.Empty;
if (!_isDisposed)
{
@@ -1,5 +1,7 @@
@namespace WebApp.Components.Shared.Components
@using Core.Services
@inject INotesService NotesService
@inject INoteNamingService NoteNamingService
@inject ISnackbar Snackbar
@inject MarkdownTablePasteService MarkdownTablePasteService
@implements IAsyncDisposable
@@ -58,7 +60,7 @@
Disabled="@_isLoading">
Edit
</MudButton>
<MudButton OnClick="Cancel">Close</MudButton>
<MudButton OnClick="Cancel">Cancel</MudButton>
}
</DialogActions>
</MudDialog>
@@ -83,7 +85,7 @@
protected override void OnInitialized()
{
_cancellationTokenSource = new CancellationTokenSource();
_pageNoteTitle = $"@{PageIdentifier}";
_pageNoteTitle = NoteNamingService.GetPageNoteTitle(PageIdentifier);
_note = new Note
{
Title = _pageNoteTitle,
@@ -240,14 +242,12 @@
if (_isDisposed) return;
if (_isEditMode)
{
// If in edit mode, cancel goes back to view mode
_isEditMode = false;
// Reload the note to discard changes
_ = LoadPageNote();
// If in edit mode, cancel closes the dialog (discarding changes)
MudDialog.Close(DialogResult.Cancel());
}
else
{
MudDialog.Cancel();
MudDialog.Close(DialogResult.Cancel());
}
}
+71
View File
@@ -0,0 +1,71 @@
using Heron.MudCalendar;
namespace WebApp.Models;
/// <summary>
/// Type discriminator for calendar item types.
/// </summary>
public enum CalendarItemType
{
Event,
Meeting
}
/// <summary>
/// Wrapper class for calendar items that can hold either a CalendarEventItem or CalendarMeetingItem.
/// This allows MudCalendar to display mixed item types while maintaining type safety.
/// </summary>
public class CalendarItemWrapper : CalendarItem
{
/// <summary>
/// Gets the type of calendar item this wrapper contains.
/// </summary>
public CalendarItemType ItemType { get; private set; }
/// <summary>
/// Gets the wrapped CalendarEventItem if ItemType is Event, otherwise null.
/// </summary>
public CalendarEventItem? EventItem { get; private set; }
/// <summary>
/// Gets the wrapped CalendarMeetingItem if ItemType is Meeting, otherwise null.
/// </summary>
public CalendarMeetingItem? MeetingItem { get; private set; }
/// <summary>
/// Parameterless constructor required by Heron.MudCalendar component.
/// </summary>
public CalendarItemWrapper()
{
// Initialize base class properties to avoid null reference issues
Text = string.Empty;
Start = DateTime.MinValue;
End = DateTime.MinValue;
}
/// <summary>
/// Creates a wrapper for a CalendarEventItem.
/// </summary>
public CalendarItemWrapper(CalendarEventItem eventItem)
{
ItemType = CalendarItemType.Event;
EventItem = eventItem;
// Delegate properties to wrapped item
Text = eventItem.Text;
Start = eventItem.Start;
End = eventItem.End;
}
/// <summary>
/// Creates a wrapper for a CalendarMeetingItem.
/// </summary>
public CalendarItemWrapper(CalendarMeetingItem meetingItem)
{
ItemType = CalendarItemType.Meeting;
MeetingItem = meetingItem;
// Delegate properties to wrapped item
Text = meetingItem.Text;
Start = meetingItem.Start;
End = meetingItem.End;
}
}
+38
View File
@@ -0,0 +1,38 @@
using Core.Entities;
using Heron.MudCalendar;
namespace WebApp.Models;
/// <summary>
/// Calendar meeting item model for Heron.MudCalendar component.
/// Maps from TeamMeetingHistory entity to calendar event format.
/// </summary>
public class CalendarMeetingItem : CalendarItem
{
/// <summary>
/// Gets the original TeamMeetingHistory data.
/// </summary>
public TeamMeetingHistory? MeetingHistoryData { get; set; }
/// <summary>
/// Parameterless constructor required by Heron.MudCalendar component.
/// </summary>
public CalendarMeetingItem()
{
// Initialize base class properties to avoid null reference issues
Text = string.Empty;
Start = DateTime.MinValue;
End = DateTime.MinValue;
}
public CalendarMeetingItem(TeamMeetingHistory meetingHistory)
{
MeetingHistoryData = meetingHistory;
// Set base class properties that the calendar component uses
Text = "Team Meeting";
// Use meeting date at 3:00 PM as default time
Start = meetingHistory.MeetingDate.Date.AddHours(15);
// Default to 1 hour duration
End = Start.AddHours(1);
}
}
+117
View File
@@ -0,0 +1,117 @@
using Core.Entities;
namespace WebApp.Models;
/// <summary>
/// Represents the state of the meeting schedule for dirty/clean tracking and persistence.
/// </summary>
public class MeetingScheduleState : IEquatable<MeetingScheduleState>
{
public HashSet<int> ScheduledTeamIds { get; set; } = [];
public HashSet<int> AbsentStudentIds { get; set; } = [];
public int TimeSlotCount { get; set; }
public HashSet<int> ExtendedTeamIds { get; set; } = [];
public HashSet<(int teamId, int timeSlotIndex, int studentId)> ExcludedStudents { get; set; } = [];
public bool Equals(MeetingScheduleState? other)
{
if (other == null) return false;
return ScheduledTeamIds.SetEquals(other.ScheduledTeamIds) &&
AbsentStudentIds.SetEquals(other.AbsentStudentIds) &&
TimeSlotCount == other.TimeSlotCount &&
ExtendedTeamIds.SetEquals(other.ExtendedTeamIds) &&
ExcludedStudents.SetEquals(other.ExcludedStudents);
}
public override bool Equals(object? obj) => Equals(obj as MeetingScheduleState);
public override int GetHashCode()
{
var hash = new HashCode();
hash.Add(ScheduledTeamIds.Count);
foreach (var id in ScheduledTeamIds.OrderBy(x => x))
hash.Add(id);
hash.Add(AbsentStudentIds.Count);
foreach (var id in AbsentStudentIds.OrderBy(x => x))
hash.Add(id);
hash.Add(TimeSlotCount);
hash.Add(ExtendedTeamIds.Count);
foreach (var id in ExtendedTeamIds.OrderBy(x => x))
hash.Add(id);
hash.Add(ExcludedStudents.Count);
foreach (var key in ExcludedStudents.OrderBy(x => x))
hash.Add(key);
return hash.ToHashCode();
}
public static MeetingScheduleState FromCurrent(
IEnumerable<Team> scheduledTeams,
IEnumerable<Student> absentStudents,
int timeSlotCount,
IEnumerable<Team> extendedTeams,
Dictionary<(int teamId, int timeSlotIndex, int studentId), bool> excludedStudents)
{
return new MeetingScheduleState
{
ScheduledTeamIds = scheduledTeams.Select(t => t.Id).ToHashSet(),
AbsentStudentIds = absentStudents.Select(s => s.Id).ToHashSet(),
TimeSlotCount = timeSlotCount,
ExtendedTeamIds = extendedTeams.Select(t => t.Id).ToHashSet(),
ExcludedStudents = excludedStudents.Keys
.Where(k => excludedStudents[k])
.ToHashSet()
};
}
public static async Task<MeetingScheduleState?> FromLocalStorage(
WebApp.LocalStorageService localStorage,
Team[] allTeams,
Student[] allStudents)
{
// Load scheduled teams
var scheduledTeamIds = await localStorage.GetIntArrayAsync("MeetingSchedule_ScheduledTeams");
var absentStudentIds = await localStorage.GetIntArrayAsync("MeetingSchedule_AbsentStudents");
var timeSlotCount = await localStorage.GetIntAsync("MeetingSchedule_TimeSlotCount", defaultValue: 2);
var extendedTeamIds = await localStorage.GetIntArrayAsync("MeetingSchedule_ExtendedTeams");
var exclusions = await localStorage.GetJsonAsync<ExcludedStudent[]>("MeetingSchedule_ExcludedStudents");
// If no state exists, return null
if (scheduledTeamIds.Length == 0 && absentStudentIds.Length == 0 &&
timeSlotCount == 2 && extendedTeamIds.Length == 0 &&
(exclusions == null || exclusions.Length == 0))
{
return null;
}
var excludedStudentsSet = new HashSet<(int teamId, int timeSlotIndex, int studentId)>();
if (exclusions != null && exclusions.Length > 0)
{
foreach (var exclusion in exclusions)
{
excludedStudentsSet.Add((exclusion.TeamId, exclusion.TimeSlotIndex, exclusion.StudentId));
}
}
return new MeetingScheduleState
{
ScheduledTeamIds = scheduledTeamIds.ToHashSet(),
AbsentStudentIds = absentStudentIds.ToHashSet(),
TimeSlotCount = timeSlotCount > 0 ? timeSlotCount : 2,
ExtendedTeamIds = extendedTeamIds.ToHashSet(),
ExcludedStudents = excludedStudentsSet
};
}
public async Task SaveToLocalStorage(WebApp.LocalStorageService localStorage)
{
await localStorage.SetIntArrayAsync("MeetingSchedule_ScheduledTeams", ScheduledTeamIds.ToArray());
await localStorage.SetIntArrayAsync("MeetingSchedule_AbsentStudents", AbsentStudentIds.ToArray());
await localStorage.SetIntAsync("MeetingSchedule_TimeSlotCount", TimeSlotCount);
await localStorage.SetIntArrayAsync("MeetingSchedule_ExtendedTeams", ExtendedTeamIds.ToArray());
var exclusions = ExcludedStudents.Select(e => new ExcludedStudent(e.teamId, e.timeSlotIndex, e.studentId)).ToArray();
await localStorage.SetJsonAsync("MeetingSchedule_ExcludedStudents", exclusions);
}
private record ExcludedStudent(int TeamId, int TimeSlotIndex, int StudentId);
}
+5
View File
@@ -194,7 +194,12 @@ builder.Services.AddScoped<Core.Services.IEventOccurrenceParserService>(sp =>
builder.Services.AddScoped<WebApp.Services.FormValidationService>();
builder.Services.AddScoped<WebApp.Services.EventDefinitionService>();
builder.Services.AddScoped<WebApp.Services.INotesService, WebApp.Services.NotesService>();
builder.Services.AddScoped<WebApp.Services.ITeamMeetingHistoryService, WebApp.Services.TeamMeetingHistoryService>();
builder.Services.AddScoped<Core.Services.INoteNamingService, Core.Services.NoteNamingService>();
builder.Services.AddScoped<WebApp.Services.MarkdownTablePasteService>();
builder.Services.AddScoped<WebApp.Services.IMeetingScheduleStateService, WebApp.Services.MeetingScheduleStateService>();
builder.Services.AddScoped<WebApp.Services.IMeetingScheduleClipboardService, WebApp.Services.MeetingScheduleClipboardService>();
builder.Services.AddScoped<WebApp.Services.IMeetingScheduleDataService, WebApp.Services.MeetingScheduleDataService>();
// State container for maintaining state per user connection (Blazor Server)
builder.Services.AddScoped<StateContainer>();
@@ -0,0 +1,21 @@
using Core.Calculation;
using Core.Entities;
using Core.Utility;
namespace WebApp.Services;
/// <summary>
/// Service for formatting meeting schedule data for clipboard operations.
/// </summary>
public interface IMeetingScheduleClipboardService
{
/// <summary>
/// Formats the entire schedule solution as text for clipboard.
/// </summary>
string FormatScheduleForClipboard(
TeamSchedulerSolution solution,
Team[] allTeams,
IEnumerable<Student> absentStudents,
Dictionary<(int teamId, int timeSlotIndex, int studentId), bool> excludedStudents,
Func<string, int> getTimeSlotIndex);
}
@@ -0,0 +1,20 @@
using Core.Entities;
using Microsoft.EntityFrameworkCore;
namespace WebApp.Services;
/// <summary>
/// Service for loading meeting schedule data from the database.
/// </summary>
public interface IMeetingScheduleDataService
{
/// <summary>
/// Loads all teams with their events and students.
/// </summary>
Task<Team[]> LoadTeamsAsync();
/// <summary>
/// Loads all students with their teams, event rankings, and related data.
/// </summary>
Task<Student[]> LoadStudentsAsync();
}
@@ -0,0 +1,59 @@
using Core.Entities;
namespace WebApp.Services;
/// <summary>
/// Service for managing meeting schedule state persistence in localStorage.
/// </summary>
public interface IMeetingScheduleStateService
{
/// <summary>
/// Loads scheduled teams from localStorage.
/// </summary>
Task<IEnumerable<Team>> LoadScheduledTeamsAsync(Team[] allTeams);
/// <summary>
/// Saves scheduled teams to localStorage.
/// </summary>
Task SaveScheduledTeamsAsync(IEnumerable<Team> scheduledTeams);
/// <summary>
/// Loads absent students from localStorage.
/// </summary>
Task<IEnumerable<Student>> LoadAbsentStudentsAsync(Student[] allStudents);
/// <summary>
/// Saves absent students to localStorage.
/// </summary>
Task SaveAbsentStudentsAsync(IEnumerable<Student> absentStudents);
/// <summary>
/// Loads time slot count from localStorage.
/// </summary>
Task<int> LoadTimeSlotCountAsync(int defaultValue = 2);
/// <summary>
/// Saves time slot count to localStorage.
/// </summary>
Task SaveTimeSlotCountAsync(int timeSlotCount);
/// <summary>
/// Loads extended teams from localStorage.
/// </summary>
Task<IEnumerable<Team>> LoadExtendedTeamsAsync(Team[] allTeams);
/// <summary>
/// Saves extended teams to localStorage.
/// </summary>
Task SaveExtendedTeamsAsync(IEnumerable<Team> extendedTeams);
/// <summary>
/// Loads excluded students from localStorage.
/// </summary>
Task<Dictionary<(int teamId, int timeSlotIndex, int studentId), bool>> LoadExcludedStudentsAsync();
/// <summary>
/// Saves excluded students to localStorage.
/// </summary>
Task SaveExcludedStudentsAsync(Dictionary<(int teamId, int timeSlotIndex, int studentId), bool> excludedStudents);
}
+1 -1
View File
@@ -19,7 +19,7 @@ public interface INotesService
/// Gets a page-specific note by page identifier.
/// </summary>
/// <param name="pageIdentifier">The page identifier (e.g., "Teams", "Registration")</param>
/// <returns>The note with title "@{pageIdentifier}" or null if not found</returns>
/// <returns>The note with title "#{pageIdentifier}" or null if not found</returns>
Task<Note?> GetPageNoteAsync(string pageIdentifier);
/// <summary>
@@ -0,0 +1,50 @@
using Core.Entities;
namespace WebApp.Services;
public interface ITeamMeetingHistoryService
{
/// <summary>
/// Gets all meeting histories within an optional date range.
/// </summary>
/// <param name="startDate">Optional start date filter</param>
/// <param name="endDate">Optional end date filter</param>
Task<IEnumerable<TeamMeetingHistory>> GetMeetingHistoriesAsync(DateTime? startDate = null, DateTime? endDate = null);
/// <summary>
/// Gets a specific meeting history by ID with teams and students included.
/// </summary>
Task<TeamMeetingHistory?> GetMeetingHistoryAsync(int id);
/// <summary>
/// Creates a new meeting history record.
/// </summary>
Task<TeamMeetingHistory> CreateMeetingHistoryAsync(TeamMeetingHistory meetingHistory);
/// <summary>
/// Updates an existing meeting history record.
/// </summary>
Task<TeamMeetingHistory> UpdateMeetingHistoryAsync(TeamMeetingHistory meetingHistory);
/// <summary>
/// Deletes a meeting history record.
/// </summary>
Task DeleteMeetingHistoryAsync(int id);
/// <summary>
/// Gets which teams met on a specific date.
/// </summary>
Task<IEnumerable<Team>> GetTeamsForDateAsync(DateTime date);
/// <summary>
/// Gets which students were present on a specific date.
/// </summary>
Task<IEnumerable<Student>> GetStudentsForDateAsync(DateTime date);
/// <summary>
/// Gets the meeting note for a specific meeting date by looking it up by title.
/// </summary>
/// <param name="meetingDate">The date of the meeting</param>
/// <returns>The note if found, null otherwise</returns>
Task<Note?> GetMeetingNoteAsync(DateTime meetingDate);
}
@@ -0,0 +1,123 @@
using System.Text;
using Core.Calculation;
using Core.Entities;
using Core.Utility;
namespace WebApp.Services;
/// <summary>
/// Service for formatting meeting schedule data for clipboard operations.
/// </summary>
public class MeetingScheduleClipboardService : IMeetingScheduleClipboardService
{
public string FormatScheduleForClipboard(
TeamSchedulerSolution solution,
Team[] allTeams,
IEnumerable<Student> absentStudents,
Dictionary<(int teamId, int timeSlotIndex, int studentId), bool> excludedStudents,
Func<string, int> getTimeSlotIndex)
{
var sb = new StringBuilder();
foreach (var timeslot in solution.TimeSlots)
{
AppendScheduledTeams(sb, timeslot, allTeams, absentStudents, excludedStudents, getTimeSlotIndex);
AppendUnscheduledStudents(sb, timeslot, solution, absentStudents);
sb.Append(Environment.NewLine);
}
return sb.ToString();
}
private void AppendScheduledTeams(
StringBuilder sb,
TeamScheduleTimeSlot timeslot,
Team[] allTeams,
IEnumerable<Student> absentStudents,
Dictionary<(int teamId, int timeSlotIndex, int studentId), bool> excludedStudents,
Func<string, int> getTimeSlotIndex)
{
var timeSlotIndex = getTimeSlotIndex(timeslot.Name);
foreach (var scheduledTeam in timeslot.Teams.OrderBy(e => e.ToString()))
{
var teamName = scheduledTeam.ToString();
if (scheduledTeam.Event.EventFormat is EventFormat.Individual)
{
sb.Append(teamName);
}
else
{
var studentsList = FormatStudentList(scheduledTeam, timeslot, timeSlotIndex, absentStudents, excludedStudents);
sb.Append($"{teamName} - {studentsList}");
}
sb.Append(Environment.NewLine);
}
}
private string FormatStudentList(
Team team,
TeamScheduleTimeSlot timeslot,
int timeSlotIndex,
IEnumerable<Student> absentStudents,
Dictionary<(int teamId, int timeSlotIndex, int studentId), bool> excludedStudents)
{
// Filter out excluded students for this team and time slot
var excludedStudentIds = excludedStudents.Keys
.Where(k => k.teamId == team.Id && k.timeSlotIndex == timeSlotIndex && excludedStudents[k])
.Select(k => k.studentId)
.ToHashSet();
var includedStudents = team.Students
.Where(s => !excludedStudentIds.Contains(s.Id))
.ToList();
// Create a temporary team with only included students for formatting
var teamForFormatting = new Team
{
Id = team.Id,
Event = team.Event,
Students = includedStudents,
Captain = team.Captain,
Identifier = team.Identifier
};
return TeamStudentNameFormatter.FormatStudentList(
teamForFormatting,
new TeamStudentNameFormatter.FormatOptions
{
Ordering = TeamStudentNameFormatter.OrderingStyle.CaptainFirst,
MarkOverlaps = true,
HasOverlaps = timeslot.StudentHasOverlaps,
MarkAbsent = true,
AbsentStudents = absentStudents.ToList()
});
}
private void AppendUnscheduledStudents(
StringBuilder sb,
TeamScheduleTimeSlot timeslot,
TeamSchedulerSolution solution,
IEnumerable<Student> absentStudents)
{
if (!timeslot.UnscheduledStudents.Any())
return;
sb.Append("--Unscheduled");
sb.Append(Environment.NewLine);
foreach (var student in timeslot.UnscheduledStudents)
{
var studentName = StudentNameFormatter.FormatStudentName(
student,
new StudentNameFormatter.FormatOptions
{
IsAbsent = absentStudents.Contains(student)
});
var unassignedTeams = solution.StudentUnassignedTeams(student);
var teamsList = string.Join(", ", unassignedTeams.Select(e => e.ToString()));
sb.Append($"{studentName} - {teamsList}");
sb.Append(Environment.NewLine);
}
}
}
@@ -0,0 +1,43 @@
using Core.Entities;
using Data;
using Microsoft.EntityFrameworkCore;
namespace WebApp.Services;
/// <summary>
/// Service for loading meeting schedule data from the database.
/// </summary>
public class MeetingScheduleDataService : IMeetingScheduleDataService
{
private readonly AppDbContext _context;
public MeetingScheduleDataService(AppDbContext context)
{
_context = context;
}
public async Task<Team[]> LoadTeamsAsync()
{
return await _context.Teams
.AsNoTracking()
.Include(e => e.Event)
.Include(e => e.Students)
.OrderBy(e => e.Event.Name)
.ThenBy(e => e.Identifier)
.ToArrayAsync();
}
public async Task<Student[]> LoadStudentsAsync()
{
return await _context.Students
.AsNoTracking()
.Include(e => e.Teams)
.ThenInclude(t => t.Event)
.Include(e => e.Teams)
.ThenInclude(t => t.Captain)
.Include(e => e.EventRankings)
.ThenInclude(e => e.EventDefinition)
.OrderBy(e => e.FirstName)
.ToArrayAsync();
}
}
@@ -0,0 +1,105 @@
using Core.Entities;
using WebApp.Models;
namespace WebApp.Services;
internal record ExcludedStudent(int TeamId, int TimeSlotIndex, int StudentId);
/// <summary>
/// Service for managing meeting schedule state persistence in localStorage.
/// </summary>
public class MeetingScheduleStateService : IMeetingScheduleStateService
{
private readonly LocalStorageService _localStorage;
private const string ScheduledTeamsKey = "MeetingSchedule_ScheduledTeams";
private const string AbsentStudentsKey = "MeetingSchedule_AbsentStudents";
private const string TimeSlotCountKey = "MeetingSchedule_TimeSlotCount";
private const string ExtendedTeamsKey = "MeetingSchedule_ExtendedTeams";
private const string ExcludedStudentsKey = "MeetingSchedule_ExcludedStudents";
public MeetingScheduleStateService(LocalStorageService localStorage)
{
_localStorage = localStorage;
}
public async Task<IEnumerable<Team>> LoadScheduledTeamsAsync(Team[] allTeams)
{
var teamIds = await _localStorage.GetIntArrayAsync(ScheduledTeamsKey);
if (teamIds.Length > 0)
{
return allTeams.Where(t => teamIds.Contains(t.Id)).ToArray();
}
return [];
}
public async Task SaveScheduledTeamsAsync(IEnumerable<Team> scheduledTeams)
{
var teamIds = scheduledTeams.Select(t => t.Id).ToArray();
await _localStorage.SetIntArrayAsync(ScheduledTeamsKey, teamIds);
}
public async Task<IEnumerable<Student>> LoadAbsentStudentsAsync(Student[] allStudents)
{
var studentIds = await _localStorage.GetIntArrayAsync(AbsentStudentsKey);
if (studentIds.Length > 0)
{
return allStudents.Where(s => studentIds.Contains(s.Id)).ToArray();
}
return [];
}
public async Task SaveAbsentStudentsAsync(IEnumerable<Student> absentStudents)
{
var studentIds = absentStudents.Select(s => s.Id).ToArray();
await _localStorage.SetIntArrayAsync(AbsentStudentsKey, studentIds);
}
public async Task<int> LoadTimeSlotCountAsync(int defaultValue = 2)
{
var timeSlots = await _localStorage.GetIntAsync(TimeSlotCountKey, defaultValue);
return timeSlots > 0 ? timeSlots : defaultValue;
}
public async Task SaveTimeSlotCountAsync(int timeSlotCount)
{
await _localStorage.SetIntAsync(TimeSlotCountKey, timeSlotCount);
}
public async Task<IEnumerable<Team>> LoadExtendedTeamsAsync(Team[] allTeams)
{
var teamIds = await _localStorage.GetIntArrayAsync(ExtendedTeamsKey);
if (teamIds.Length > 0)
{
return allTeams.Where(t => teamIds.Contains(t.Id)).ToArray();
}
return [];
}
public async Task SaveExtendedTeamsAsync(IEnumerable<Team> extendedTeams)
{
var teamIds = extendedTeams.Select(t => t.Id).ToArray();
await _localStorage.SetIntArrayAsync(ExtendedTeamsKey, teamIds);
}
public async Task<Dictionary<(int teamId, int timeSlotIndex, int studentId), bool>> LoadExcludedStudentsAsync()
{
var exclusions = await _localStorage.GetJsonAsync<ExcludedStudent[]>(ExcludedStudentsKey);
if (exclusions != null && exclusions.Length > 0)
{
return exclusions.ToDictionary(
e => (e.TeamId, e.TimeSlotIndex, e.StudentId),
_ => true);
}
return new Dictionary<(int teamId, int timeSlotIndex, int studentId), bool>();
}
public async Task SaveExcludedStudentsAsync(Dictionary<(int teamId, int timeSlotIndex, int studentId), bool> excludedStudents)
{
var exclusions = excludedStudents.Keys
.Where(k => excludedStudents[k])
.Select(k => new ExcludedStudent(k.teamId, k.timeSlotIndex, k.studentId))
.ToArray();
await _localStorage.SetJsonAsync(ExcludedStudentsKey, exclusions);
}
}
+12 -8
View File
@@ -1,4 +1,5 @@
using Core.Entities;
using Core.Services;
using Data;
using Microsoft.EntityFrameworkCore;
using System.Security.Claims;
@@ -10,15 +11,18 @@ public class NotesService : INotesService
private readonly AppDbContext _context;
private readonly IHttpContextAccessor _httpContextAccessor;
private readonly ILogger<NotesService> _logger;
private readonly INoteNamingService _noteNamingService;
public NotesService(
AppDbContext context,
IHttpContextAccessor httpContextAccessor,
ILogger<NotesService> logger)
ILogger<NotesService> logger,
INoteNamingService noteNamingService)
{
_context = context;
_httpContextAccessor = httpContextAccessor;
_logger = logger;
_noteNamingService = noteNamingService;
}
private string? GetCurrentUserEmail()
@@ -42,7 +46,7 @@ public class NotesService : INotesService
}
return await query
.OrderBy(n => n.Title.StartsWith("@") ? 1 : 0) // Non-page notes first (0), page notes last (1)
.OrderBy(n => n.Title != null && n.Title.StartsWith("#") ? 1 : 0) // Non-page notes first (0), page notes last (1)
.ThenByDescending(n => n.UpdatedAt) // Within each group, order by most recently updated
.ToListAsync();
}
@@ -56,7 +60,7 @@ public class NotesService : INotesService
public async Task<Note?> GetPageNoteAsync(string pageIdentifier)
{
var pageNoteTitle = $"@{pageIdentifier}";
var pageNoteTitle = _noteNamingService.GetPageNoteTitle(pageIdentifier);
return await _context.Notes
.AsNoTracking()
.Where(n => n.Title == pageNoteTitle && !n.IsDeleted)
@@ -184,7 +188,7 @@ public class NotesService : INotesService
{
return await _context.Notes
.AsNoTracking()
.Where(n => n.IsPinned && !n.Title.StartsWith("@") && !n.IsDeleted)
.Where(n => n.IsPinned && (n.Title == null || !n.Title.StartsWith("#")) && !n.IsDeleted)
.OrderByDescending(n => n.UpdatedAt)
.Take(3)
.ToListAsync();
@@ -201,7 +205,7 @@ public class NotesService : INotesService
}
// Prevent pinning page notes
if (note.Title.StartsWith("@"))
if (_noteNamingService.IsPageNote(note.Title))
{
throw new InvalidOperationException("Page notes cannot be pinned.");
}
@@ -213,13 +217,13 @@ public class NotesService : INotesService
if (!note.IsPinned)
{
var pinnedCount = await _context.Notes
.CountAsync(n => n.IsPinned && !n.Title.StartsWith("@") && !n.IsDeleted);
.CountAsync(n => n.IsPinned && (n.Title == null || !n.Title.StartsWith("#")) && !n.IsDeleted);
if (pinnedCount >= 3)
{
// Unpin the oldest pinned note
var oldestPinned = await _context.Notes
.Where(n => n.IsPinned && !n.Title.StartsWith("@") && !n.IsDeleted)
.Where(n => n.IsPinned && (n.Title == null || !n.Title.StartsWith("#")) && !n.IsDeleted)
.OrderBy(n => n.UpdatedAt)
.FirstOrDefaultAsync();
@@ -250,7 +254,7 @@ public class NotesService : INotesService
return await _context.Notes
.AsNoTracking()
.Where(n => n.IsDeleted)
.OrderBy(n => n.Title.StartsWith("@") ? 1 : 0) // Non-page notes first (0), page notes last (1)
.OrderBy(n => n.Title != null && n.Title.StartsWith("#") ? 1 : 0) // Non-page notes first (0), page notes last (1)
.ThenByDescending(n => n.UpdatedAt) // Within each group, order by most recently updated
.ToListAsync();
}
@@ -0,0 +1,205 @@
using Core.Entities;
using Core.Services;
using Data;
using Microsoft.EntityFrameworkCore;
using System.Security.Claims;
namespace WebApp.Services;
public class TeamMeetingHistoryService : ITeamMeetingHistoryService
{
private readonly AppDbContext _context;
private readonly IHttpContextAccessor _httpContextAccessor;
private readonly ILogger<TeamMeetingHistoryService> _logger;
private readonly INotesService _notesService;
private readonly INoteNamingService _noteNamingService;
public TeamMeetingHistoryService(
AppDbContext context,
IHttpContextAccessor httpContextAccessor,
ILogger<TeamMeetingHistoryService> logger,
INotesService notesService,
INoteNamingService noteNamingService)
{
_context = context;
_httpContextAccessor = httpContextAccessor;
_logger = logger;
_notesService = notesService;
_noteNamingService = noteNamingService;
}
private string? GetCurrentUserEmail()
{
var user = _httpContextAccessor.HttpContext?.User;
if (user == null)
return null;
return user.FindFirstValue(ClaimTypes.Email) ?? user.Identity?.Name;
}
public async Task<IEnumerable<TeamMeetingHistory>> GetMeetingHistoriesAsync(DateTime? startDate = null, DateTime? endDate = null)
{
var query = _context.TeamMeetingHistories
.AsNoTracking()
.Include(tmh => tmh.Teams)
.ThenInclude(t => t.Event)
.Include(tmh => tmh.Students)
.AsQueryable();
if (startDate.HasValue)
{
var start = startDate.Value.Date;
query = query.Where(tmh => tmh.MeetingDate >= start);
}
if (endDate.HasValue)
{
var end = endDate.Value.Date.AddDays(1); // Include the entire end date
query = query.Where(tmh => tmh.MeetingDate < end);
}
return await query
.OrderByDescending(tmh => tmh.MeetingDate)
.ToListAsync();
}
public async Task<TeamMeetingHistory?> GetMeetingHistoryAsync(int id)
{
return await _context.TeamMeetingHistories
.Include(tmh => tmh.Teams)
.ThenInclude(t => t.Event)
.Include(tmh => tmh.Teams)
.ThenInclude(t => t.Students)
.Include(tmh => tmh.Students)
.FirstOrDefaultAsync(tmh => tmh.Id == id);
}
public async Task<TeamMeetingHistory> CreateMeetingHistoryAsync(TeamMeetingHistory meetingHistory)
{
// Create a new meeting history entity to avoid tracking conflicts
var newMeetingHistory = new TeamMeetingHistory
{
MeetingDate = meetingHistory.MeetingDate.Date // Normalize to date only
};
// Attach teams by loading them from the database to avoid tracking conflicts
var teamIds = meetingHistory.Teams.Select(t => t.Id).ToList();
var teams = await _context.Teams
.Where(t => teamIds.Contains(t.Id))
.ToListAsync();
// Attach students by loading them from the database to avoid tracking conflicts
var studentIds = meetingHistory.Students.Select(s => s.Id).ToList();
var students = await _context.Students
.Where(s => studentIds.Contains(s.Id))
.ToListAsync();
// Attach teams and students to the new meeting history
newMeetingHistory.Teams = teams;
newMeetingHistory.Students = students;
_context.TeamMeetingHistories.Add(newMeetingHistory);
await _context.SaveChangesAsync();
_logger.LogInformation("Meeting history created: {MeetingHistoryId} for date {MeetingDate}",
newMeetingHistory.Id, newMeetingHistory.MeetingDate);
return newMeetingHistory;
}
public async Task<TeamMeetingHistory> UpdateMeetingHistoryAsync(TeamMeetingHistory meetingHistory)
{
var existingHistory = await _context.TeamMeetingHistories
.Include(tmh => tmh.Teams)
.Include(tmh => tmh.Students)
.FirstOrDefaultAsync(tmh => tmh.Id == meetingHistory.Id);
if (existingHistory == null)
{
throw new InvalidOperationException($"Meeting history with ID {meetingHistory.Id} not found.");
}
// Update properties
existingHistory.MeetingDate = meetingHistory.MeetingDate.Date; // Normalize to date only
// Update teams
existingHistory.Teams.Clear();
foreach (var team in meetingHistory.Teams)
{
var existingTeam = await _context.Teams.FindAsync(team.Id);
if (existingTeam != null)
{
existingHistory.Teams.Add(existingTeam);
}
}
// Update students
existingHistory.Students.Clear();
foreach (var student in meetingHistory.Students)
{
var existingStudent = await _context.Students.FindAsync(student.Id);
if (existingStudent != null)
{
existingHistory.Students.Add(existingStudent);
}
}
await _context.SaveChangesAsync();
_logger.LogInformation("Meeting history updated: {MeetingHistoryId} by {User}",
meetingHistory.Id, GetCurrentUserEmail());
return existingHistory;
}
public async Task DeleteMeetingHistoryAsync(int id)
{
var meetingHistory = await _context.TeamMeetingHistories
.FirstOrDefaultAsync(tmh => tmh.Id == id);
if (meetingHistory == null)
{
throw new InvalidOperationException($"Meeting history with ID {id} not found.");
}
_context.TeamMeetingHistories.Remove(meetingHistory);
await _context.SaveChangesAsync();
_logger.LogInformation("Meeting history deleted: {MeetingHistoryId}", id);
}
/// <summary>
/// Gets the meeting note for a specific meeting date by looking it up by title.
/// </summary>
/// <param name="meetingDate">The date of the meeting</param>
/// <returns>The note if found, null otherwise</returns>
public async Task<Note?> GetMeetingNoteAsync(DateTime meetingDate)
{
var noteTitle = _noteNamingService.GetMeetingNoteTitle(meetingDate);
var notes = await _notesService.GetNotesAsync(includeDeleted: false);
return notes.FirstOrDefault(n => n.Title == noteTitle);
}
public async Task<IEnumerable<Team>> GetTeamsForDateAsync(DateTime date)
{
var normalizedDate = date.Date;
return await _context.TeamMeetingHistories
.AsNoTracking()
.Where(tmh => tmh.MeetingDate == normalizedDate)
.SelectMany(tmh => tmh.Teams)
.Include(t => t.Event)
.Distinct()
.ToListAsync();
}
public async Task<IEnumerable<Student>> GetStudentsForDateAsync(DateTime date)
{
var normalizedDate = date.Date;
return await _context.TeamMeetingHistories
.AsNoTracking()
.Where(tmh => tmh.MeetingDate == normalizedDate)
.SelectMany(tmh => tmh.Students)
.Distinct()
.ToListAsync();
}
}