Add Team functions
This commit is contained in:
@@ -32,7 +32,10 @@ public class EventDefinition
|
||||
|| SemifinalistActivity.Contains("Speech")
|
||||
|| SemifinalistActivity.Contains("Test")
|
||||
|| SemifinalistActivity.Contains("Flight")
|
||||
|| Name.Contains("Leadership")
|
||||
|| Name.Contains("Forensic")
|
||||
|| Name.Contains("Flight")
|
||||
|| Name.Contains("Coding")
|
||||
|| SemifinalistActivity.Contains("Debate")
|
||||
|| SemifinalistActivity.Contains("Photography")
|
||||
|| SemifinalistActivity.Contains("Build")
|
||||
|
||||
@@ -8,6 +8,6 @@ public class PartialTeam : Team
|
||||
{
|
||||
var remainingStudents = Students.Where(s => !studentsToOmit.Contains(s)).ToList();
|
||||
var omittedStudents = OmittedStudents.Union(Students.Where(studentsToOmit.Contains)).Distinct().ToList();
|
||||
return new PartialTeam{TeamId = Name, Event = Event, Students = remainingStudents, OmittedStudents = omittedStudents };
|
||||
return new PartialTeam{TeamId = TeamId, Event = Event, Students = remainingStudents, OmittedStudents = omittedStudents };
|
||||
}
|
||||
}
|
||||
@@ -3,7 +3,7 @@ using static System.Text.RegularExpressions.Regex;
|
||||
|
||||
namespace Core.Entities;
|
||||
|
||||
public class Student
|
||||
public class Student : IEquatable<Student>
|
||||
{
|
||||
public int Id { get; set; }
|
||||
|
||||
@@ -74,4 +74,23 @@ public class Student
|
||||
|
||||
public bool VotingDelegate => OfficerRole is Entities.OfficerRole.President or Entities.OfficerRole.VicePresident;
|
||||
|
||||
public bool Equals(Student? other)
|
||||
{
|
||||
if (other is null) return false;
|
||||
if (ReferenceEquals(this, other)) return true;
|
||||
return Id == other.Id;
|
||||
}
|
||||
|
||||
public override bool Equals(object? obj)
|
||||
{
|
||||
if (obj is null) return false;
|
||||
if (ReferenceEquals(this, obj)) return true;
|
||||
if (obj.GetType() != GetType()) return false;
|
||||
return Equals((Student)obj);
|
||||
}
|
||||
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return Id;
|
||||
}
|
||||
}
|
||||
@@ -7,6 +7,6 @@ public class StudentEventRanking
|
||||
public EventDefinition EventDefinition { get; set; } = null!;
|
||||
public int Rank { get; set; }
|
||||
|
||||
public const int MaxRank = 6;
|
||||
public const int MaxRank = 10;
|
||||
|
||||
}
|
||||
+11
-37
@@ -5,10 +5,15 @@ public class Team
|
||||
{
|
||||
public int Id { get; set; }
|
||||
|
||||
[Required]
|
||||
[Required]
|
||||
[Display(Name = "Team Name")]
|
||||
public string Name { get; set; }
|
||||
public EventDefinition Event { get; set; }
|
||||
public int? Number { get; set; }
|
||||
public EventDefinition Event
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
public List<Student> Students { get; set; } = [];
|
||||
|
||||
public Student? Captain { get; set; }
|
||||
@@ -16,8 +21,6 @@ public class Team
|
||||
[Display(Name = "Team Id")]
|
||||
public string? TeamId { get; set; }
|
||||
|
||||
//public string? RegionalTimeSlot { get; set; }
|
||||
|
||||
|
||||
// public Tuple<DateTime,DateTime?>? RegionalTimeSlotObj
|
||||
//{
|
||||
@@ -51,46 +54,17 @@ public class Team
|
||||
var studentsToOmitList = studentsToOmit.ToList();
|
||||
var omittedStudents = Students.Where(studentsToOmitList.Contains).ToList();
|
||||
if (!omittedStudents.Any())
|
||||
return new Team{Captain = Captain, Event = Event, Students = Students.ToList(), TeamId = Name};
|
||||
return new Team{Captain = Captain, Event = Event, Students = Students.ToList(), TeamId = TeamId, Number = Number};
|
||||
|
||||
var remainingStudents = Students.Where(s => !studentsToOmitList.Contains(s)).ToList();
|
||||
return new PartialTeam { Name = Name, Event = Event, Students = remainingStudents, OmittedStudents = omittedStudents};
|
||||
return new PartialTeam { Number = Number, Event = Event, Students = remainingStudents, OmittedStudents = omittedStudents};
|
||||
}
|
||||
|
||||
public Team Clone() => CloneWithOmittedStudents([]);
|
||||
|
||||
public static int GetStudentTeamOverlapCount(IList<Team>[] timeSlots)
|
||||
{
|
||||
return timeSlots.Sum(GetStudentTeamOverlapCount);
|
||||
}
|
||||
|
||||
private static int GetStudentTeamOverlapCount(IList<Team> timeSlot)
|
||||
{
|
||||
return GetStudentTeamOverlaps(timeSlot).Count();
|
||||
}
|
||||
|
||||
public static IEnumerable<Tuple<Student, IEnumerable<Team>>> GetStudentTeamOverlaps(IList<Team> timeSlot)
|
||||
{
|
||||
return
|
||||
from s in timeSlot.SelectMany(ts => ts.Students).Distinct()
|
||||
group s by timeSlot.Where(t => t.Students.Contains(s))
|
||||
into gs
|
||||
where gs.Key.Count() > 1
|
||||
select Tuple.Create(gs.First(), gs.Key);
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return Name;
|
||||
}
|
||||
|
||||
public string ToStringWithIndividualAndRegional()
|
||||
{
|
||||
var ind = Event.EventFormat is EventFormat.Individual ? " (Ind.)" : string.Empty;
|
||||
var regional= Event.RegionalEvent ? " (Reg.)" : string.Empty;
|
||||
//var regional= Event.RegionalEvent ? " (Reg.)" : string.Empty;
|
||||
|
||||
var eventAttributes = Event.EventAttributes();
|
||||
return string.IsNullOrEmpty(eventAttributes) ? Name : Name + " (" + eventAttributes + ")";
|
||||
return $"{Event.Name} {(Number != null ? $"(#{Number})" : "")}";
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user