Keep legal first and last names for formal lists; show DisplayFirstName on teams, calendars, and import matching so two Josiahs can be told apart. Co-authored-by: Cursor <cursoragent@cursor.com>
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.DisplayFirstName;
|
|
|
|
// Add overlap marker
|
|
if (options.HasOverlap)
|
|
{
|
|
name += "*";
|
|
}
|
|
|
|
// Add absent marker
|
|
if (options.IsAbsent)
|
|
{
|
|
name += " (absent)";
|
|
}
|
|
|
|
return name;
|
|
}
|
|
}
|