public static List <CertificateData> GenerateCertificates(ACompetitor Competitor, AEvent Event)
        {
            // All error checking moved to hasEarnedCertificate() for efficacy.
            //if ( Event == null )
            //    throw new ArgumentNullException ( "Event can not be null when generating certificates" );

            //if ( Competitor == null )
            //    throw new ArgumentNullException ( "Competitor can not be null when generating certificates" );

            //if ( Competitor.CompetingIn != Event )
            //    throw new ArgumentException ( "Competitor must be competing for the Event used as a parameter" );

            //if ( Event.Results.Count ( ) == 0 )
            //    // There are not results to process certificates for
            //    return new List<CertificateData> ( );

            //if ( Event.Results.Where ( r => r.Competitor == Competitor ).Count ( ) == 0 )
            //    // This competitor does not appear in this events results
            //    return new List<CertificateData> ( );

            if (Competitor?.Result?.CertificateEarned == true)
            {
                return(Event.getCertificateData( ).Where(c => c.Competitor == Competitor).ToList( ));
            }
            else
            {
                return(new List <CertificateData> ( ));
            }
        }
Ejemplo n.º 2
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");
            }
        }
Ejemplo n.º 3
0
        // How do we handle heat that are run into finals
        protected override AResult addResult(int Rank, ACompetitor Competitor, ResultValue resultValue, string VestNumber = "")
        {
            if (Competitor is IHeatedCompetitor competitor)
            {
                // We know this result is for the final so promote the competitor and add it.
                if (HeatRunAsFinal)
                {
                    promoteCompetitorToFinal(competitor);
                    //competitor.promoteToFinal ( );
                    return(base.addResult(Rank, Competitor, resultValue, VestNumber));
                }

                if (this.promotedCompetitors( ).Contains(Competitor))
                {
                    // We know this result is for the final so just add it.
                    return(base.addResult(Rank, Competitor, resultValue, VestNumber));
                }
                else
                {
                    // Move this competitor to the final and add the result
                    competitor.promoteToFinal( );
                    return(base.addResult(Rank, Competitor, resultValue, VestNumber));
                }


                // This result could be for a heat
                //foreach (IndividualTimedHeatEvent heat in Heats)
                //{
                //    // skip this heat if this competitor is not in it.
                //    if (!heat.hasCompetitor((Competitor)Competitor)) continue;

                //    if (heat.hasResultFor(Competitor))
                //    {
                //        // This competitor should be in the final so we'll promote them now.
                //        promoteCompetitorToFinal(competitor);

                //        // Now we can add the result.
                //        return base.addResult(Rank, Competitor, resultValue);
                //    }
                //    else
                //    {
                //        // add the result to the heat
                //        return heat.AddHeatResult(Rank, competitor, resultValue);
                //    }
                //}

                // is not in a heat
                throw new ArgumentException("This Competitor is not in the final or the heat run as final flag is not set.");
            }
            else
            {
                return(base.addResult(Rank, Competitor, resultValue, VestNumber));
                //throw new ArgumentException("Competitor must be an individual");
            }
        }
Ejemplo n.º 4
0
        public bool Equals(ACompetitor c)
        {
            // If parameter is null return false:
            if ((object)c == null)
            {
                return(false);
            }

            // Return true if the fields match:
            return(ID == c.ID);
        }
Ejemplo n.º 5
0
 protected override AResult addResult(int Rank, ACompetitor Competitor, ResultValue resultValue, string VestNumber = "")
 {
     // on 2015-06-12 changed to always store a heats result in the heat rather than check with the final
     //return Final.AddResult(Rank, Competitor, resultValue);
     if (Competitor is IHeatedCompetitor hc)
     {
         hc.HeatEvent = this;
         Competitor.Save( );
         return(AddHeatResult(Rank, hc, resultValue));
     }
     throw new Exception("Competitor must inherit from IHeatedCompetitor");
 }
Ejemplo n.º 6
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);
            }
        }
Ejemplo n.º 7
0
        public override bool Equals(System.Object obj)
        {
            // If parameter is null return false.
            if (obj == null)
            {
                return(false);
            }

            // If parameter cannot be cast to Point return false.
            ACompetitor c = obj as ACompetitor;

            if ((System.Object)c == null)
            {
                return(false);
            }

            // Return true if the fields match:
            return(ID == c.ID);
        }
 public static List <CertificateData> GenerateCertificates(ACompetitor Competitor)
 {
     return(GenerateCertificates(Competitor, Competitor.CompetingIn));
 }
Ejemplo n.º 9
0
 public override void removeCompetitor(ACompetitor Competitor)
 {
     Final.removeCompetitor(Competitor);
 }
Ejemplo n.º 10
0
 /// <summary>
 /// Check if a competitor has been entered into this heat.
 /// </summary>
 /// <param name="Competitor">Competitor to check.</param>
 /// <returns>True if the competitor is in this heat.</returns>
 public bool hasCompetitor(ACompetitor Competitor)
 {
     //return (Final.allCompetitorsinHeat( this ).Contains( Competitor ));
     return(Final.EnteredCompetitors.Contains(Competitor));
 }
Ejemplo n.º 11
0
        // 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;
        }
Ejemplo n.º 12
0
 public override void removeCompetitor(ACompetitor Competitor)
 {
     base.removeCompetitor(Competitor);
 }
Ejemplo n.º 13
0
 public AResult AddResult(ACompetitor Competitor, decimal distanceResultValue)
 {
     return(addResult(0, Competitor, new ResultValue(this.ResultsDisplayDescription, distanceResultValue)));
 }
Ejemplo n.º 14
0
 public AResult AddResult(ACompetitor Competitor, TimeSpan timedResultValue)
 {
     return(addResult(0, Competitor, new ResultValue(this.ResultsDisplayDescription, timedResultValue)));
 }
Ejemplo n.º 15
0
        internal override List <CertificateData> buildCertificateData(ACompetitor Competitor, string CertificateType, int counter, ScoringTeam ScoringTeam = null)
        {
            List <CertificateData> temp = new List <CertificateData>();

            if (Competitor == null)
            {
                return(temp);
            }

            if (Competitor.getResult() == null)
            {
                return(temp);
            }

            if (!Competitor.getResult().Rank.HasValue)
            {
                // this competitor was not ranked.
                return(temp);
            }

            Squad squad = (Squad)Competitor;

            foreach (Athlete a in squad.members)
            {
                if (a == null)
                {
                    continue;
                }

                string SchStr = string.Empty;
                if (a is StudentAthlete)
                {
                    SchStr = ((StudentAthlete)a).Attends.Name;
                }

                // modified 2015-06-07 to add PrintName

                CertificateData CD = new CertificateData()
                {
                    Championship    = this.Championship.ToString(),
                    TeamName        = Competitor.getTeam().Name,
                    CompetitorsName = a.PrintName(),
                    EventName       = this.Name,
                    SchoolName      = SchStr,
                    CertifiacteType = CertificateType,
                    Competitor      = Competitor,
                    RankCounter     = counter
                };

                if (this.customFieldExists("PrintedName"))
                {
                    CD.EventName = this.getValue("PrintedName").ToString();
                }

                switch (CertificateType)
                {
                case "TopIndividuals":

                    CD.CertificateName = "Top Individuals";

                    // CompetitorsName updated for SW 2014-15
                    //CD.CompetitorsName = String.Format("{0} - {1}", Competitor.getName(), Competitor.getTeam().Name);
                    CD.CompetitorsName = String.Format("{0}", a.PrintName());

                    // SchoolName field updated for SW 2014-15
                    CD.SchoolName = String.Format("{0} - {1}", Competitor.getTeam().Name, SchStr);

                    //CD.Rank = AResult.IntToString( Competitor.getResult().Rank.Value );
                    CD.Rank = CD.Competitor.Result.printRankAndResult();
                    break;

                case "TopLowerYearGroupIndividuals":
                    // Not used in SW 2014-15
                    CD.CertificateName = "Top Lower Year Group Individuals";
                    CD.CompetitorsName = String.Format("{0} - {1} - ({2})", a.PrintName(), Competitor.getTeam().Name, Competitor.getResult().Rank.Value.ToString());

                    CD.Rank = string.Format("{0} Year {1}", AResult.IntToString(counter), ((StudentCompetitor)Competitor).YearGroup.ToString());

                    break;

                case "Team":
                    // updated for SW 2014-15
                    //CD.CompetitorsName = String.Format("{0} - {1} - ({2})", Competitor.getTeam().Name, Competitor.getName(), Competitor.Result.Rank.Value.ToString());
                    CD.CompetitorsName = String.Format("{1} - ({2})", Competitor.getTeam().Name, Competitor.getName(), Competitor.getResult().Rank.Value.ToString());
                    // SchoolName field updated for SW 2014-15
                    CD.SchoolName = String.Format("{0} - {1}", Competitor.getTeam().Name, SchStr);

                    if (ScoringTeam != null)
                    {
                        // updated for SW 2014-15
                        CD.Rank = string.Format("{0} Team", AResult.IntToString(ScoringTeam.Rank), ScoringTeam.ScoringTeamName);
                        //CD.Rank = string.Format("{0} {1} Team", AResult.IntToString(ScoringTeam.Rank), ScoringTeam.ScoringTeamName);
                        CD.CertificateName = CD.Rank;
                    }

                    CD.CertificateName = CD.Rank;

                    break;

                default:
                    break;
                }

                temp.Add(CD);
            } // for each member
            return(temp);
        }
Ejemplo n.º 16
0
        protected override AResult addResult(int Rank, ACompetitor Competitor, ResultValue resultValue, string VestNumber = "")
        {
            AResult newResult;

            // Check that this competitor hasn't already got a result
            if (Competitor != null)
            {
                if (hasResultFor(Competitor))
                {
                    throw new ArgumentException("This competitor already has a result in this race!");
                }
            }

            if (Rank == 0)
            {
                Rank = getNextResultRank();
            }

            // removes any placeholder for this rank
            removePlaceholder(Rank);

            if (!isRankAvailable(Rank))
#if (ReorderResults)
            { makeSpaceForResult(Rank); }
#else
            { throw new ArgumentException(string.Format("Rank {0} has already been used", Rank)); }
#endif

            // No competitor or value
            if (Competitor == null && !resultValue.HasValue())
            {
                //newResult = new Result(ResultTypeDescription.Placeholder) { Event = this, Rank = Rank };
                newResult = new Result()
                {
                    Event = this, Rank = Rank, VestNumber = DM.VestNumber.MakeFromString(VestNumber)
                };
                AddResult(newResult);
                return(newResult);
            }

            // No competitor but does have a value
            if (Competitor == null && resultValue.HasValue())
            {
                //newResult = new Result(ResultTypeDescription.ValuePlaceholder) { Event = this, Rank = Rank, Value = resultValue };
                newResult = new Result()
                {
                    Event = this, Rank = Rank, Value = resultValue, VestNumber = DM.VestNumber.MakeFromString(VestNumber)
                };
                AddResult(newResult);
                return(newResult);
            }

            // Competitor but no result value
            if (Competitor != null && !resultValue.HasValue())
            {
                //newResult = new Result(ResultTypeDescription.Competative) { Event = this, Rank = Rank, Competitor = Competitor };
                newResult = new Result()
                {
                    Event = this, Rank = Rank, Competitor = Competitor
                };
                AddResult(newResult);
                return(newResult);
            }

            // Competitor and result value
            if (Competitor != null && resultValue.HasValue())
            {
                //newResult = new Result(ResultTypeDescription.CompetativeWithValue) { Event = this, Competitor = Competitor, Rank = Rank, Value = resultValue };
                newResult = new Result()
                {
                    Event = this, Competitor = Competitor, Rank = Rank, Value = resultValue
                };
                AddResult(newResult);
                return(newResult);
            }

            throw new ArgumentException("Unknown exception when adding a result");
        }