Example #1
0
        /// <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;
                }
            }
        }
Example #2
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);
        }
Example #3
0
 internal void addAthlete(AthleteTeamChamptionship atc)
 {
     //!**! I don't think this is needed anymore
     //_Athletes.Add(atc);
 }
Example #4
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;
        }