45edcf5e5f
This commit removes the obsolete EventAssignment class from Core.Entities and introduces new models in Core.Models, including AssignmentParameters, AssignmentRequirement, PartialTeam, and StudentEventStatistics. The changes enhance the organization of assignment-related data and improve the overall structure of the codebase. Additionally, several files have been updated to include references to the new Core.Models namespace, ensuring consistency across the application.
79 lines
2.2 KiB
C#
79 lines
2.2 KiB
C#
using System.ComponentModel.DataAnnotations;
|
|
using Core.Models;
|
|
|
|
namespace Core.Entities;
|
|
public class Team
|
|
{
|
|
public int Id { get; set; }
|
|
|
|
[Required]
|
|
public EventDefinition Event { get; set; } = null!;
|
|
|
|
public List<Student> Students { get; set; } = [];
|
|
|
|
public Student? Captain { get; set; }
|
|
|
|
[Display(Name = "Team Identifier")]
|
|
[StringLength(32)]
|
|
public string? Identifier { get; set; }
|
|
|
|
|
|
// public Tuple<DateTime,DateTime?>? RegionalTimeSlotObj
|
|
//{
|
|
// get
|
|
// {
|
|
|
|
// if (string.IsNullOrEmpty(RegionalTimeSlot))
|
|
// return null;
|
|
// var times = Regex.Matches(RegionalTimeSlot, @"(.*)\s*-\s*(.*)");
|
|
// if (times.Count == 0)
|
|
// return Tuple.Create(P(RegionalTimeSlot), (DateTime?)null);
|
|
// var match = times[0];
|
|
// if (!match.Success)
|
|
// return Tuple.Create(P(RegionalTimeSlot), (DateTime?)null);
|
|
|
|
// return Tuple.Create(P(match.Groups[1].Value), (DateTime?)P(match.Groups[2].Value));
|
|
// return null;
|
|
// }
|
|
//}
|
|
|
|
private DateTime P(string s)
|
|
{
|
|
var dt = DateTime.Parse(s);
|
|
if (dt.TimeOfDay < TimeSpan.FromHours(7))
|
|
return dt + TimeSpan.FromHours(12);
|
|
return dt;
|
|
}
|
|
|
|
public virtual Team CloneWithOmittedStudents(IEnumerable<Student> studentsToOmit)
|
|
{
|
|
var studentsToOmitList = studentsToOmit.ToList();
|
|
var omittedStudents = Students.Where(studentsToOmitList.Contains).ToList();
|
|
if (omittedStudents.Count == 0)
|
|
return new Team{Captain = Captain, Event = Event, Students = Students.ToList(), Identifier = Identifier, Id = Id};
|
|
|
|
var remainingStudents = Students.Where(s => !studentsToOmitList.Contains(s)).ToList();
|
|
return new PartialTeam { Event = Event, Students = remainingStudents, OmittedStudents = omittedStudents, Identifier = Identifier, Id = Id};
|
|
}
|
|
|
|
public Team Clone() => CloneWithOmittedStudents([]);
|
|
|
|
|
|
public override string ToString()
|
|
{
|
|
return $"{Event.Name} {(Identifier != null ? $"({Identifier})" : "")}";
|
|
}
|
|
|
|
public string StudentsFirstNames
|
|
{
|
|
get
|
|
{
|
|
return
|
|
string.Join(", ",
|
|
Students.Select(e =>
|
|
e.FirstName
|
|
+ (Captain != null && (Captain.Equals(e)) ? "(Cpt)" : ""))
|
|
);
|
|
}
|
|
}
|
|
} |