Exemple #1
0
        /// <summary>
        /// Will remove the competitor from the final and all heats.
        /// To Do check heat for results before removing
        /// </summary>
        public override void removeCompetitor(ACompetitor Competitor)
        {
            if (Competitor.getResult() == null)
            {
                // 2015-06-12 I've commented out the remove from heat command as the competitor is only stored in the final.
                //// remove from each of the heats
                foreach (IndividualTimedHeatEvent heat in Heats)
                {
                    if (heat.hasCompetitor((Competitor)Competitor))
                    {
                        // ToDo checking for results this way will not work!
                        if (heat.hasResultFor(Competitor))
                        {
                            throw new ArgumentException("Can not remove this competitor from this event as they have a result");
                        }
                    }
                }
                //else
                //            heat.EnteredCompetitors.Remove(Competitor);

                // remove from final
                if (EnteredCompetitors.Contains(Competitor))
                {
                    this.RemoveCompetitor(Competitor);
                }
            }
            else
            {
                throw new ArgumentException("Can not remove this competitor from this event as they have a result");
            }
        }
Exemple #2
0
        public override void enterAthlete(Athlete Athlete, VestNumber Vest, bool Guest = false)
        {
            if (isEventFull())
            {
                throw new ArgumentException(String.Format("{0} is already full with {1} competitors.", Name, getEnteredCompetitors().Count));
            }

            if (isTeamFull(Athlete.getTeam(this.Championship)))
            {
                throw new ArgumentException(String.Format("{0} is already full with {1} competitors.", Name, getEnteredCompetitors(Athlete.getTeam(this.Championship)).Count));
            }

            if (EnteredCompetitors.Count(i => i.isAthlete(Athlete)) != 0)
            {
                throw new ArgumentException("Athlete has already been entered");
            }

            StudentCompetitor comp = new StudentCompetitor(Athlete, Vest, this);

            comp.Guest = Guest;

            this.AddCompetitor(comp);

            Athlete.voidStorage( );
        }
Exemple #3
0
 public override List <ACompetitor> getEnteredCompetitors()
 {
     // 2016-06-28 HeatRunAsFinal concept has been removed as lane draw for final is no longer required.
     //if (HeatRunAsFinal)
     return(EnteredCompetitors.ToList( ).OrderBy(p => p.Vest.IntOrder).ToList( ));
     //else
     //return promotedCompetitors();
 }
Exemple #4
0
        public override void removeAthlete(Athlete Athlete)
        {
            if (Athlete == null)
            {
                return;
            }

            ACompetitor c = EnteredCompetitors.Where(e => e.isAthlete(Athlete)).FirstOrDefault();

            if (c != null)
            {
                this.removeCompetitor(c);
            }
        }
Exemple #5
0
        public override void removeAthlete(Athlete Athlete)
        {
            if (Athlete == null)
            {
                return;
            }

            Squad s = (Squad)EnteredCompetitors.Where(e => e.isAthlete(Athlete)).FirstOrDefault();

            if (s != null)
            {
                if (s.Competitor1 != null)
                {
                    if (s.Competitor1 == Athlete)
                    {
                        s.Competitor1 = null;
                    }
                }

                if (s.Competitor2 != null)
                {
                    if (s.Competitor2 == Athlete)
                    {
                        s.Competitor2 = null;
                    }
                }

                if (s.Competitor3 != null)
                {
                    if (s.Competitor3 == Athlete)
                    {
                        s.Competitor3 = null;
                    }
                }

                if (s.Competitor4 != null)
                {
                    if (s.Competitor4 == Athlete)
                    {
                        s.Competitor4 = null;
                    }
                }
            }

            if (s.isSquadEmpty())
            {
                this.removeCompetitor(s);
            }
        }
Exemple #6
0
        public List <ACompetitor> allCompetitorsinHeat(IHeatEvent Event)
        {
            List <ACompetitor> temp = new List <ACompetitor>();

            foreach (ACompetitor comp in EnteredCompetitors.OrderBy(p => p.Vest.IntOrder))
            {
                //2017-06-03
                temp.Add(comp);
            }

            //if ( comp is IHeatedCompetitor)
            //        if (((IHeatedCompetitor)comp).HeatEvent == (AEvent)Event)
            //            temp.Add(comp);

            return(temp);
        }
Exemple #7
0
        public override void enterAthlete(Athlete Athlete, VestNumber Vest, bool Guest = false)
        {
            if (isEventFull())
            {
                throw new ArgumentException(String.Format("{0} is already full with {1} competitors.", Name, getEnteredCompetitors().Count));
            }

            if (isTeamFull(Athlete.getTeam(this.Championship)))
            {
                throw new ArgumentException(String.Format("{0} is already full with {1} competitors.", Name, getEnteredCompetitors(Athlete.getTeam(this.Championship)).Count));
            }

            if (EnteredCompetitors.Count(i => i.isAthlete(Athlete)) != 0)
            {
                throw new ArgumentException("Athlete has already been entered");
            }

            if (!isAvailable(Athlete))
            {
                throw new ArgumentException("Athlete is not eligible for this event");
            }

            // find if there is already a squad for this team.

            Team t = Athlete.getTeam(this.Championship);

            if (t == null)
            {
                return;
            }

            Squad comp = getSquadForTeam(t);

            if (comp == null)
            {
                comp = new Squad()
                {
                    CompetingIn = this, Vest = Vest
                };
                this.AddCompetitor(comp);
            }

            comp.addToSquad(Athlete);

            comp.Guest = Guest;
        }
Exemple #8
0
        public override bool canBeEntered(Athlete athlete)
        {
            //if (isEventFull())
            //    return false;

            //if (isTeamFull(Athlete.getTeam(this.Championship)))
            //    return false;

            if (EnteredCompetitors.Count(i => i.isAthlete(athlete)) != 0)
            {
                return(false);
            }

            if (!isAvailable(athlete))
            {
                return(false);
            }

            // To do is the following statement actually true? 2015-06-02
            // You can never enter a single athlete into a squad event

            Team t = athlete.getTeam(this.Championship);

            // no team, no entry!
            if (t == null)
            {
                return(false);
            }

            Squad s = getSquadForTeam(t);

            // no squad so we can make a new one.
            if (s == null)
            {
                return(true);
            }

            // the squad has at least one empty space
            if (!s.isSquadFull())
            {
                return(true);
            }

            return(false);
        }
Exemple #9
0
        public override bool requiresLaneUpdate()
        {
            foreach (IndividualTimedHeatEvent heat in Heats)
            {
                if (heat.requiresLaneUpdate( ))
                {
                    return(true);
                }
            }

            // don't bother with lane assignments if this event was run as a heat.
            if (HeatRunAsFinal)
            {
                return(false);
            }


            // do not have to update an empty event
            if (EnteredCompetitors.Count() == 0)
            {
                return(false);
            }

            // do not want to update lanes on an event which has already got results
            if (AllResults().Count > 0)
            {
                return(false);
            }

            if (promotedCompetitors().Count() == 0)
            {
                return(true);
            }

            foreach (ILanedCompetitor c in promotedCompetitors())
            {
                if (!c.hasLaneNumber())
                {
                    return(true);
                }
            }

            return(false);
        }
Exemple #10
0
        public override bool canBeEntered(Athlete Athlete)
        {
            if (isEventFull())
            {
                return(false);
            }

            if (isTeamFull(Athlete.getTeam(this.Championship)))
            {
                return(false);
            }

            if (EnteredCompetitors.Count(i => i.isAthlete(Athlete)) != 0)
            {
                return(false);
            }

            if (!isAvailable(Athlete))
            {
                return(false);
            }

            return(true);
        }
Exemple #11
0
        public virtual bool requiresLaneUpdate( )
        {
            // do not have to update an empty event
            if (EnteredCompetitors.Count() == 0)
            {
                return(false);
            }

            // do not want to update lanes on an event which has already got results
            if (AllResults().Count > 0)
            {
                return(false);
            }

            foreach (ILanedCompetitor c in getEnteredCompetitors())  // EnteredCompetitors)
            {
                if (!c.hasLaneNumber())
                {
                    return(true);
                }
            }

            return(false);
        }