Add Blazor WebApp and rework data handling to utilize Entity Framework

This commit is contained in:
2025-09-11 11:49:48 -04:00
parent 5220e61c79
commit 3daa3b81b3
111 changed files with 6039 additions and 946 deletions
+62 -59
View File
@@ -1,74 +1,77 @@
using System.Text.RegularExpressions;
using System.ComponentModel.DataAnnotations;
using static System.Text.RegularExpressions.Regex;
namespace Core.Entities;
public class Student
{
public string Name { get; set; }
public int Id { get; set; }
public string LastNameFirstName
[Required]
[StringLength(50,MinimumLength = 2)]
[Display(Name = "First Name")]
public string FirstName { get; set; }
[Required]
[StringLength(50, MinimumLength = 2)]
[Display(Name = "Last Name")]
public string LastName { get; set; }
[Range(5,12)]
[Display(Name = "Grade")]
public int Grade { get; set; }
[EmailAddress]
[Display(Name = "Email Address")]
public string? Email { get; set; }
[Phone]
[Display(Name = "Phone Number")]
public string? PhoneNumber { get; set; }
[Display(Name = "TSA Year")]
public int TsaYear { get; set; }
[Display(Name = "State Id")]
public string? StateId { get; set; }
[Display(Name = "Regional Id")]
public string? RegionalId { get; set; }
[Display(Name = "National Id")]
public string? NationalId { get; set; }
[Display(Name = "Officer Role")]
public OfficerRole? OfficerRole { get; set; }
public List<Team> Teams { get; set; } = null;
public List<EventDefinition> RankedEvents { get; } = [];
public List<StudentEventRanking> EventRankings { get; } = [];
public string Name => FirstNameLastName;
public string LastNameFirstName => $"{LastName}, {FirstName}";
public string FirstNameLastName => $"{FirstName} {LastName}";
public static Tuple<string, string> ParseNameParts(string fullName)
{
get
{
if (Name.Contains(',')) return Name;
var match = Regex.Match(Name, @"(.*)\s(.*)");
if (match.Success)
return $"{match.Groups[2].Value}, {match.Groups[2].Value} ";
return Name;
}
var match = Match(fullName, @"(.*),\s*(.*)");
if (match.Success)
return Tuple.Create(match.Groups[2].Value, match.Groups[1].Value);
match = Match(fullName, @"(.*)\s*(.*)");
return
match.Success
? Tuple.Create(match.Groups[1].Value, match.Groups[2].Value)
: new Tuple<string, string>(fullName, string.Empty);
}
public string FirstNameLastName
{
get
{
if (!Name.Contains(',')) return Name;
var match = Regex.Match(Name, @"(.*),\s*(.*)");
if (match.Success)
return $"{match.Groups[2].Value} {match.Groups[1].Value}";
return Name;
}
}
public string FirstName
{
get
{
var match = Regex.Match(LastNameFirstName, @"(.*),\s*(.*)");
if (match.Success)
return $"{match.Groups[2].Value}";
return Name;
}
}
public int Grade { get; }
public string StateID { get; }
public string RegionalID { get; }
public string NationalID { get; }
public int TsaYear { get; }
public string Officer { get; }
public IList<CompetitiveEvent> RankedEventPicks { get; }
public ICollection<Team> Teams { get; set; }
public Student(string name, int grade, int tsaYear, string officer, IList<CompetitiveEvent> rankedEventPicks,
string stateID, string regionalID, string nationalId)
{
Name = name;
Grade = grade;
TsaYear = tsaYear;
Officer = officer;
RankedEventPicks = rankedEventPicks;
StateID=stateID;
RegionalID = regionalID;
NationalID = nationalId;
}
public override string ToString()
{
return FirstName;
}
public bool VotingDelegate => Officer.Contains("Pres");
public bool VotingDelegate => OfficerRole is Entities.OfficerRole.President or Entities.OfficerRole.VicePresident;
}