8af86e22d9
This commit updates various files across the Core and WebApp projects to replace traditional collection initializers with C# 12 collection expressions. Changes include modifications to EventAssignment.cs, TeamScheduler_DecisionTree.cs, CareerField.cs, EventDefinition.cs, and several components in the WebApp. These updates enhance code readability and maintainability by adhering to modern C# syntax standards.
52 lines
1.4 KiB
C#
52 lines
1.4 KiB
C#
using Core.Entities;
|
|
namespace Core.Parsers;
|
|
|
|
public class StudentParser : CsvParserBase
|
|
{
|
|
public StudentParser(FileSystemInfo csvFile, bool ignoreBlankLines = true) : base(csvFile, ignoreBlankLines)
|
|
{
|
|
}
|
|
|
|
public StudentParser(StreamReader reader, bool ignoreBlankLines = true) : base(reader, ignoreBlankLines)
|
|
{
|
|
}
|
|
|
|
public Student[] Parse()
|
|
{
|
|
var students = new List<Student>();
|
|
|
|
CsvReader.Read();
|
|
CsvReader.ReadHeader();
|
|
|
|
while (CsvReader.Read())
|
|
{
|
|
var name = CsvReader.GetField("Student Name");
|
|
if (string.IsNullOrEmpty(name))
|
|
continue;
|
|
|
|
var (firstName, lastName) = Student.ParseNameParts(name);
|
|
|
|
|
|
var stateId = CsvReader.GetField("State ID")?.Trim();
|
|
var regionalId = CsvReader.GetField("Regional ID")?.Trim();
|
|
var nationalId = CsvReader.GetField("National ID")?.Trim();
|
|
var grade = CsvReader.GetField("Grade");
|
|
var tsaYearsStr = CsvReader.GetField("TSA year");
|
|
var tsaYear = int.Parse(tsaYearsStr?[..1] ?? "1");
|
|
|
|
var student = new Student
|
|
{
|
|
FirstName = firstName,
|
|
LastName = lastName,
|
|
Grade = Convert.ToInt32(grade),
|
|
TsaYear = tsaYear,
|
|
StateId = stateId,
|
|
RegionalId = regionalId,
|
|
NationalId = nationalId
|
|
};
|
|
students.Add(student);
|
|
}
|
|
|
|
return students.ToArray();
|
|
}
|
|
} |