internal void EnterAthletes( )
        {
            foreach (AthleteStorage athlete in Athletes)
            {
                try {
                    DM.Athlete ath;

                    if (athlete.GlobalID != 0)
                    {
                        ath = FileIO.FConnFile.GetFileDetails( ).IO.GetID <DM.Athlete> (athlete.GlobalID);

                        if (ath == null)
                        {
                            ath = new DM.Athlete( );
                        }
                    }
                    else
                    {
                        ath = new DM.Athlete( );
                    }

                    ath.setFullName(athlete.Name);
                    FileIO.FConnFile.GetFileDetails( ).IO.Update <DM.Person> (ath);
                    ath.setTeam(athlete.Team, ((App)App.Current).CurrentChampionship.Championship);
                    ath.Attends     = athlete.School;
                    ath.DateOfBirth = athlete.DateOfBirth;
                    ath.Gender      = athlete.Gender;

                    FileIO.FConnFile.GetFileDetails( ).IO.Update <DM.Person> (ath);

                    foreach (string EventCode in athlete.EventCodes)
                    {
                        DM.AEvent Event = (DM.AEvent)((App)App.Current).CurrentChampionship.Championship.getEventShortName(EventCode);
                        if (Event == null)
                        {
                            throw new Exception($"Event with code '{EventCode}' could not be found in the database.");
                        }
                        Event.enterAthlete(ath);
                    }
                }
                catch (Exception ex)
                {
                    var result = MessageBox.Show("Failed to enter an athlete " + athlete.Name + "\n" + ex.Message + "\nDo you wish to abort the rest of the import process?"
                                                 , "Import Error", MessageBoxButton.YesNo, MessageBoxImage.Error, MessageBoxResult.No);

                    Console.WriteLine("Failed to enter an athlete " + athlete.Name);
                    Console.WriteLine(ex.Message);
                    if (result == MessageBoxResult.Yes)
                    {
                        Console.WriteLine("Aborted import process");
                        return;
                    }
                    continue;
                }
            }
        }
Exemple #2
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 #3
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);
            }
        }
        public List <AEvent> listAllAvailableEvents(Athlete Athlete)
        {
            List <AEvent> Events = new List <AEvent>();

            foreach (AEvent Event in listAllAvailableEvents(this, Athlete))
            {
                //if (Event.canBeEntered(Athlete))
                Events.Add(Event);
            }

            return(Events);


            //return listAllAvailableEvents(this, Athlete);
        }
Exemple #5
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 #6
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 #7
0
        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 <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);
        }
Exemple #9
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);
        }
 public PowerOfTenResult(Athlete Athlete, DateTime DateStamp, string Championship, string Event, string Rank, string ResultValue, DateTime EventDate) : base(Athlete, DateStamp, Championship, Event, Rank, ResultValue, EventDate)
 {
 }
        //private DataAccess.Database _database;
        //public DataAccess.Database database
        //{
        //    get
        //    {
        //        return _database;
        //    }
        //    set
        //    {
        //        _database = value;
        //        DState.IO = value;
        //        DState.NeedsUpdating = true;
        //    }
        //}

        public static Championship copyChampionship(string newChampionshipName, Championship origonalChampionship, DataAccess.Database Connection, Team team = null)
        {
            Championship newChamp = new Championship(newChampionshipName, origonalChampionship.AgeDateReference);

            newChamp.Location   = origonalChampionship.Location;
            newChamp.Locked     = origonalChampionship.Locked;
            newChamp.ShortName  = origonalChampionship.ShortName;
            newChamp._FixedName = origonalChampionship.FixedName;

            Connection.Add <Championship>(newChamp);

            // Restrictions
            foreach (Group res in origonalChampionship.Groups)
            {
                newChamp.addGroup(Group.CopyGroup(res));
            }

#if (!TeamTesting)
            // Teams (and schools)
            Team[] teams;
            if (team == null)
            {
                teams = origonalChampionship.Teams;
            }
            else
            {
                teams = new Team[] { team }
            };

            foreach (Team t in teams)
            {
                Team t2 = new Team(t.Name, newChamp)
                {
                    ShortName = t.ShortName
                };
                newChamp.addTeam(t2);

                foreach (School sch in t.HasSchools)
                {
                    School s2 = new DM.School(sch.Name);
                    s2.ShortName = sch.ShortName;
                    Connection.Add <School>(s2);

                    t2.AddSchool(s2, Connection);

                    foreach (var athlete in  origonalChampionship.DState.IO.GetAll <Athlete>().Where(a => a.Attends == sch))
                    {
                        // copy athlete

                        Athlete a = new Athlete( )
                        {
                            FirstName       = athlete.FirstName,
                            MiddleName      = athlete.MiddleName,
                            LastName        = athlete.LastName,
                            PreferredName   = athlete.PreferredName,
                            Attends         = s2,
                            GlobalAthleteID = athlete.GlobalAthleteID,
                            DateOfBirth     = athlete.DateOfBirth,
                            Gender          = athlete.Gender,
                            Suffix          = athlete.Suffix,
                            Title           = athlete.Title
                        };

                        Connection.Add <Person>(a);

                        // copy athlete notes

                        foreach (var note in athlete._Notes)
                        {
                            if (note.GetType( ) == typeof(ConfidentialNote))
                            {
                                a.AddNote(new ConfidentialNote(note));
                            }
                            else if (note.GetType( ) == typeof(PublicNote))
                            {
                                a.AddNote(new PublicNote((PublicNote)note));
                            }
                            // 2017-03-26
                            // Deliberately not copying availability information between championships!
                            // this could be a mistake.
                            //else if ( note.GetType() == typeof(DeclaredAvailibilityInformation ))
                            //    a.AddNote( new DeclaredAvailibilityInformation( (DeclaredAvailibilityInformation)note ) );
                            else if (note.GetType( ) == typeof(PowerOfTenResult))
                            {
                                a.AddNote(new PowerOfTenResult((PowerOfTenResult)note));
                            }
                            else if (note.GetType( ) == typeof(PreviousResult))
                            {
                                a.AddNote(new PreviousResult((PreviousResult)note));
                            }
                        }


                        // copy athlete contacts

                        foreach (var contact in athlete.Contacts)
                        {
                            AContactDetail detail = null;

                            if (contact is EmailContactDetail)
                            {
                                detail = new EmailContactDetail(((EmailContactDetail)contact).EmailAddress, contact.ContactName);
                            }

                            if (contact is AddressContactDetail)
                            {
                                detail = new AddressContactDetail(
                                    contact.ContactName,
                                    ((AddressContactDetail)contact).FirstLine,
                                    ((AddressContactDetail)contact).SecondLine,
                                    ((AddressContactDetail)contact).ThirdLine,
                                    ((AddressContactDetail)contact).FourthLine,
                                    ((AddressContactDetail)contact).PostCode);
                            }

                            if (contact is PhoneContactDetail)
                            {
                                detail = new PhoneContactDetail( )
                                {
                                    ContactName = contact.ContactName,
                                    phoneNumber = ((PhoneContactDetail)contact).phoneNumber
                                }
                            }
                            ;

                            if (contact is MobileContactDetail)
                            {
                                detail = new MobileContactDetail( )
                                {
                                    ContactName = contact.ContactName,
                                    phoneNumber = ((MobileContactDetail)contact).phoneNumber
                                }
                            }
                            ;


                            if (detail != null)
                            {
                                a.AddContact(detail);
                            }
                        }
                    }

                    origonalChampionship.DState.IO.DeleteRange <Person>(
                        origonalChampionship.DState.IO.GetAll <Athlete>( ).Where(a => a.Attends == sch).ToArray());
                }
            }
#endif

            // Events (not competitors or results)
            foreach (AEvent Event in origonalChampionship.listAllEvents( ))
            {
                AEvent.CopyEvent(Event, newChamp);
            }


            // Custom Data
            CustomData.CopyCustomData(origonalChampionship.CustomDataStore, newChamp);

            newChamp.Save( );

            return(newChamp);
        }
Exemple #12
0
 public abstract bool isAthlete(Athlete athlete);
Exemple #13
0
 public Competitor(Athlete athlete, VestNumber Vest, AEvent inEvent)
 {
     this.Athlete     = athlete;
     this.Vest        = Vest;
     this.CompetingIn = inEvent;
 }
Exemple #14
0
 public Competitor(Athlete athlete)
 {
     Athlete = athlete;
 }
Exemple #15
0
 public override bool isAthlete(Athlete athlete)
 {
     return(Athlete == athlete);
 }
Exemple #16
0
 public StudentCompetitor(Athlete athlete, VestNumber Vest, AEvent inEvent) : base(athlete, Vest, inEvent)
 {
 }
Exemple #17
0
        /// <summary>
        /// To Do - maybe?
        /// </summary>
        /// <param name = "st" ></ param >
        /// < returns ></ returns >
        //protected override List<CertificateData> getCertificatesTeams(ScoringTeam st)
        //{
        //    throw new NotImplementedException();
        //    return Final.getCertificatesTeams(st);
        //}

        #endregion

        #region Competitor

        //public override ACompetitor getCompetitor(string Vest)
        //{
        //    return allCompetitorsinHeat().Where(c => c.Vest.ToString() == Vest).FirstOrDefault();
        //}

        public override void enterAthlete(Athlete Athlete, VestNumber Vest, bool Guest = false)
        {
            Final.enterAthlete(Athlete, Vest, Guest);
        }
Exemple #18
0
 get => CalculateYearGroup(Athlete, CompetingIn.Championship);
        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);
        }