Beispiel #1
0
        protected virtual void DoPromotion()
        {
            //if hasParent and AmountToPromote > 0
            if (ParentCompetitionId != null && PromoteToParentCompetition > 0)
            {
                //select top x of the league to promote
                var targets =
                    CompetitionLeagueTable.GetStandings(this, (int)Country.Season).Take(PromoteToParentCompetition);

                foreach (var item in targets)
                {
                    item.Club.Competition = ParentCompetition;
                }
                WorldState.GetDatabaseContext().SaveChanges();
            }
        }
Beispiel #2
0
        protected virtual void DoRelegation()
        {
            //if hasChild and AmountToRelegate > 0
            if (ChildCompetitionId != null && RelegateToChildCompetition > 0)
            {
                //select bottom x of the league to relegate
                var targets =
                    CompetitionLeagueTable.GetStandingsBackwards(this, (int)Country.Season).Take(RelegateToChildCompetition);

                foreach (var item in targets)
                {
                    item.Club.Competition = ChildCompetition;
                }
                WorldState.GetDatabaseContext().SaveChanges();
            }
        }