Files
chapter-organizer/WebApp/Models/ChapterSettings.cs
T
poprhythmandCursor 4cfd85b902 feat: import leftover student fields into notes and show them on the roster
Store leftover CSV columns on hidden student notes, move catalog import to /events/import, and persist Students index columns from Chapter Settings.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-08-29 23:55:03 -04:00

79 lines
2.5 KiB
C#

using Core.Models;
using Core.Notes;
using Microsoft.Extensions.Configuration;
namespace WebApp.Models;
/// <summary>
/// Configuration for chapter-specific information
/// </summary>
public class ChapterSettings
{
/// <summary>
/// Full chapter name (e.g., "Your Chapter Name")
/// </summary>
public string Name { get; set; } = "Your Chapter Name";
/// <summary>
/// Short chapter name abbreviation (e.g., "YCN")
/// </summary>
public string ShortName { get; set; } = "YCN";
/// <summary>
/// National chapter ID (4 digits, e.g., "0000")
/// </summary>
public string NationalId { get; set; } = "0000";
/// <summary>
/// State chapter ID (5 digits, e.g., "00000")
/// </summary>
public string StateId { get; set; } = "00000";
/// <summary>
/// Regional chapter ID (5 digits, e.g., "00000")
/// </summary>
public string RegionalId { get; set; } = "00000";
/// <summary>
/// Competition year (e.g., "2026")
/// </summary>
public string CompetitionYear { get; set; } = "2026";
/// <summary>
/// National TSA yearly theme (e.g., "Unity Through Community")
/// </summary>
public string YearlyTheme { get; set; } = "Unity Through Community";
/// <summary>
/// Postal state abbreviation for printed schedules (example placeholder: "ST").
/// </summary>
public string StateAbbrev { get; set; } = "ST";
/// <summary>
/// School level for the chapter (null = import both MS and HS events)
/// </summary>
public SchoolLevel? SchoolLevel { get; set; }
/// <summary>
/// Field names from student note <c>## Imported fields</c> tables to show as Students index columns.
/// </summary>
public List<string> StudentIndexNoteFields { get; set; } = [.. StudentNoteFieldDefaults.IndexColumns];
public static ChapterSettings FromConfiguration(IConfiguration configuration)
{
var settings = configuration.GetSection("ChapterSettings").Get<ChapterSettings>()
?? new ChapterSettings();
settings.StudentIndexNoteFields = ReadIndexNoteFields(configuration);
return settings;
}
public static List<string> ReadIndexNoteFields(IConfiguration configuration)
{
var fields = configuration.GetSection("ChapterSettings:StudentIndexNoteFields").Get<List<string>>();
if (fields is null)
return [.. StudentNoteFieldDefaults.IndexColumns];
return [.. fields.Where(f => !string.IsNullOrWhiteSpace(f)).Select(f => f.Trim())];
}
}