public List <ACompetitor> getSelectedForNextEvent(Championship Championship) { List <ACompetitor> comps = new List <ACompetitor>(); foreach (AEvent Event in Championship.listAllEvents()) { foreach (ACompetitor EC in Event.EnteredCompetitors.Where(c => c.printParameter("Attends") == Name && c.SelectedForNextEvent)) { bool isSame = false; foreach (ACompetitor C in comps) { if (C.isAthlete(((Competitor)EC).Athlete)) { isSame = true; break; } } if (!isSame) { comps.Add(EC); } } } return(comps); }
/// <summary> /// Gets all results for an athlete in a specified Championship including heat results. /// </summary> public List <AResult> getAllResults(Championship Championship = null) { List <AResult> results = new List <AResult>(); List <ACompetitor> competing;//= new List<ACompetitor>(); if (Championship == null) { competing = _Competitors.ToList <ACompetitor> ( ); } else { //competing = this.CompetingAs ( Championship ); competing = GetCompetitors(Championship).ToList <ACompetitor> ( ); } foreach (Competitor c in competing) { if (c is StudentHeatedCompetitor) { if (((StudentHeatedCompetitor)c).getHeatResult( ) != null) { results.Add(((StudentHeatedCompetitor)c).getHeatResult( )); } } if (c.getResult( ) != null) { results.Add(c.getResult( )); } } return(results); }
/// <summary> /// Joins this athlete to a team for a specific championship. /// It can also clear the Attends field if the new team does not also have that school/club. /// </summary> /// <param name="team"></param> /// <param name="championship"></param> public void setTeam(Team team, Championship championship) { if (getTeam(championship) == team) { return; // nothing has changed } if (GetCompetitors(championship).Count( ) > 0) { throw new Exception("Can not set team after events have been entered"); } AthleteTeamChamptionship championships = (from c in Teams where c.Championship == championship && c.Athlete == this select c).FirstOrDefault(); if (team == null) { // Delete the link record in AthleteTeamChampionship // Sadly the auto delete on Null in System.Data.Linq fails here and tries to also delete the Team record as well as the ATC link. // so the actual link deletion takes place in AthleteVM.cs if (championship == null) { return; // there is nothing to do here } DState.IO.Delete <AthleteTeamChamptionship> (championship); } else { if (championships == null) // set Team for the first time { championships = new AthleteTeamChamptionship() { Athlete = this, Championship = championship, Team = team }; DState.IO.Add <AthleteTeamChamptionship> (championships); } else // Change team { championships.Team.voidStorage( ); championships.Team = team; DState.IO.Update <AthleteTeamChamptionship> (championships); } } championships.Team.voidStorage( ); championships.voidStorage( ); __AthleteTeamChampionship.refresh( ); if (Attends != null) { if (!Attends.inTeams.Contains(team)) { Attends = null; } } }
public bool forChampionship(Championship Championship) { // Added 2016-03-25 if (CompetingIn == null) { return(false); } return(CompetingIn.Championship == Championship); }
public IndividualTimedFinalEvent(IndividualTimedFinalEvent Event, Championship Championship) : base(Event, Championship) { MaxCompetitorsPerHeat = Event.MaxCompetitorsPerHeat; foreach (IndividualTimedHeatEvent heat in Event.Heats) { copyHeat(this, heat); } }
public static List <CertificateData> GenerateCertificates(Championship Championship) { List <CertificateData> temp = new List <CertificateData>(); foreach (AEvent Event in Championship.listAllEvents( )) { temp.AddRange(ACertificate.GenerateCertificates(Event)); } return(temp); }
public bool CanDelete( ) { if (Championship == null) { return(true); } if (Championship.isLocked( )) { return(false); } // 2016-05-29 optimised by not using getAllAthletes which instantiates each athlete. return(Athletes.Count( ) == 0); //return ( getAllAthletes ( ).Count == 0 ); }
// 2016-03-25 this may not work for Squads public AEvent getPreferedEvent(Championship Championship) { AthleteTeamChamptionship atc = (from t in Teams where t.Championship.Name == Championship.Name select t).FirstOrDefault(); if (atc == null) { return(null); } if (atc.PreferedEvent == null) { return(null); } return(atc.PreferedEvent.CompetingIn); }
static public int CalculateYearGroup(Athlete Athlete, Championship Championship) { if (Athlete == null) { return(0); } if (!Athlete.DateOfBirth.HasValue) { return(0); } // ToDo is the minus 5 really constant here!? 2016-11-06 if (Championship.AgeDateReference.HasValue) { return(Athlete.getAge(Championship.AgeDateReference.Value).Years - 5); } return(0); }
public static List <AEvent> listAllAvailableEvents(Championship Championship, Athlete Athlete) { List <AEvent> Events = new List <AEvent>(); // Can not enter an athlete that isn't in a team. if (Athlete.getTeam(Championship) == null) { return(Events); } foreach (AEvent Event in Championship.listAllEvents()) { //if (Event.isAvailable( Athlete ) ) if (Event.canBeEntered(Athlete)) { Events.Add(Event); } } return(Events); }
public static List <CertificateData> GenerateCertificates(Athlete Athlete, Championship Championship = null) { List <CertificateData> temp = new List <CertificateData>(); //List<Competitor> competitors = new List<Competitor>(); List <ACompetitor> competitors = new List <ACompetitor>(); if (Championship == null) { competitors.AddRange(Athlete._Competitors); } else { competitors.AddRange(Athlete.GetCompetitors(Championship)); } foreach (Competitor competitor in competitors) { temp.AddRange(GenerateCertificates(competitor)); } return(temp); }
public SquadDistanceEvent(SquadDistanceEvent Event, Championship Championship) : base(Event, Championship) { }
public IndividualTimedFinalSchoolEvent(IndividualTimedFinalSchoolEvent Event, Championship Championship) : base(Event, Championship) { this.LowerYearGroup = Event.LowerYearGroup; }
/// <summary> /// List the Athletes that fall within a restriction from a list of Athletes who are in a specified Team. /// </summary> /// <param name="prospectiveAthletes">Athletes to be checked for suitability.</param> /// <param name="fromTeam">The team you want to look within.</param> /// <returns>A list of Athletes that can be entered.</returns> virtual public List <Athlete> listAvailableAthletes(List <Athlete> prospectiveAthletes, Team fromTeam, Championship Championship) { return(listAvailableAthletes(prospectiveAthletes.Where(i => i.getTeam(Championship) == fromTeam).ToList( ))); }
public DoBRestriction(DateTime startDate, DateTime endDate, Championship Championship) : base("Date Restriction", Championship) { _range = new TimeRange(startDate, endDate); //Championship.addRestriction(this); }
public DoBRestriction(Championship Championship) : base("Date of Birth Restriction", Championship) { }
// 2016-03-25 this may not work for Squads public void setPreferedEvent(Championship Championship, ACompetitor Competitor) { AthleteTeamChamptionship atc = Teams.Where(a => a.Championship == Championship).FirstOrDefault(); atc.PreferedEvent = Competitor; }
public bool inChampionship(Championship Championship) { return(((from t in Teams where t.Championship == Championship select t).FirstOrDefault()) != null); }
public Group(string Name, Championship Championship) : this( Name ) { this.Championship = Championship; this.Championship.addGroup(this); }
public ACompetitor getCompetitorIn(Championship Championship, AEvent Event) { return(_Competitors.Where(e => e.CompetingIn == Event && e.CompetingIn.Championship == Championship).FirstOrDefault()); }
public int CountSelected(Championship Championship) { return(getSelectedForNextEvent(Championship).Count); }
public Team(string TeamName, Championship Championship) : this( TeamName ) { this.Championship = Championship; }
public List <Competitor> GetCompetitors(Championship Championship) { return(_Competitors.Where(e => e.forChampionship(Championship) == true && e is Competitor).Select(c => c as Competitor).ToList( )); }
public Team getTeam(Championship championship) { //return (from t in Teams where t.Athlete.PrintName() == this.PrintName() && t.Championship.Name == championship.Name select t.Team).FirstOrDefault(); return((from t in Teams where t.Championship.Name == championship.Name select t.Team).FirstOrDefault()); }
public IndividualTimedHeatEvent(string Name, ResultDisplayDescription ResultType, Championship Championship) : base(Name, ResultType, Championship) { }
public GenderRestriction(Championship Championship) : base("Gender Restriction", Championship) { }
public IndividualTimedHeatEvent(IndividualTimedHeatEvent Event, IndividualTimedFinalEvent Final, Championship Championship) : base(Event, Championship) { this.Final = Final; }
public AgeRestriction(Championship Championship) : base("Age Restriction", Championship) { dateReference = DateTime.Now; //Championship.addRestriction(this); }
public Team[] TeamsForChampionship(Championship Championship) { return((from t in Teams where t.Team.Championship == Championship select t.Team).ToArray( )); }
public List <AEvent> CompetitngIn(Championship Championship) { return(_Competitors.Where(e => e.forChampionship(Championship) == true).Select(e => e.CompetingIn).ToList()); }