コード例 #1
0
        public virtual List <SeasonDivisionRule> GetChildDivisions(SeasonDivisionRule parentRule)
        {
            var result = new List <SeasonDivisionRule>();

            DivisionRules.Where(dr => dr.Parent != null && dr.Parent.DivisionName == parentRule.DivisionName).ToList().ForEach(division =>
            {
                result.Add(division);
                result.AddRange(GetChildDivisions(division));
            });

            return(result);
        }
コード例 #2
0
        //todo properly test these with years
        public virtual void ProcessDivisionRules(Season season, Dictionary <string, SeasonDivision> seasonDivisions)
        {
            //first create all the divisions
            DivisionRules.Where(dr => dr.IsActive(season.Year)).ToList().ForEach(rule =>
            {
                seasonDivisions.Add(rule.DivisionName, new SeasonDivision(season, null, season.Year, rule.DivisionName, rule.Level, rule.Ordering, null));
            });

            //now setup parent divisions relationships
            DivisionRules.Where(dr => dr.IsActive(season.Year)).ToList().ForEach(rule =>
            {
                if (rule.Parent != null)
                {
                    seasonDivisions[rule.DivisionName].ParentDivision = seasonDivisions[rule.Parent.DivisionName];
                }
            });
        }
コード例 #3
0
        public virtual List <SeasonTeamRule> GetTeamsInDivision(string divisionName)
        {
            var list = new List <SeasonTeamRule>();

            var divisionRule = DivisionRules.Where(dr => dr.DivisionName.Equals(divisionName)).FirstOrDefault();
            var parent       = divisionRule;

            if (divisionRule.Teams != null)
            {
                list.AddRange(divisionRule.Teams);
            }

            GetChildDivisions(divisionRule).ForEach(dr =>
            {
                if (dr.Teams != null)
                {
                    list.AddRange(dr.Teams);
                }
            });

            return(list);
        }