f8c22690d4
This commit introduces two new utility classes: StudentNameFormatter and TeamStudentNameFormatter, which provide methods for formatting student names with options for indicating absence and overlaps. The Team class has been updated to remove the StudentsFirstNames property, and various components across the WebApp have been refactored to utilize the new formatting utilities. This enhances the maintainability and readability of the code while improving the presentation of student names in the UI.
54 lines
1.4 KiB
C#
54 lines
1.4 KiB
C#
using Core.Entities;
|
|
|
|
namespace Core.Utility;
|
|
|
|
/// <summary>
|
|
/// Utility class for formatting individual student names with overlap and absent markers.
|
|
/// </summary>
|
|
public static class StudentNameFormatter
|
|
{
|
|
/// <summary>
|
|
/// Options for formatting student names.
|
|
/// </summary>
|
|
public record FormatOptions
|
|
{
|
|
/// <summary>
|
|
/// Whether the student is absent. If true, adds "(absent)" suffix. Default is false.
|
|
/// </summary>
|
|
public bool IsAbsent { get; init; } = false;
|
|
|
|
/// <summary>
|
|
/// Whether the student has schedule overlaps. If true, adds "*" suffix. Default is false.
|
|
/// </summary>
|
|
public bool HasOverlap { get; init; } = false;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Formats a single student name with overlap and absent markers.
|
|
/// </summary>
|
|
/// <param name="student">The student to format.</param>
|
|
/// <param name="options">Formatting options.</param>
|
|
/// <returns>Formatted student name.</returns>
|
|
public static string FormatStudentName(Student student, FormatOptions options)
|
|
{
|
|
if (student == null)
|
|
return string.Empty;
|
|
|
|
var name = student.FirstName;
|
|
|
|
// Add overlap marker
|
|
if (options.HasOverlap)
|
|
{
|
|
name += "*";
|
|
}
|
|
|
|
// Add absent marker
|
|
if (options.IsAbsent)
|
|
{
|
|
name += " (absent)";
|
|
}
|
|
|
|
return name;
|
|
}
|
|
}
|