internal IEnumerable <TwinRinksEvent> GetEvents(string team)
        {
            if (TwinRinksScheduleParserUtils.TryParseTeamLevelAndMoniker(team, out TwinRinksTeamLevel level, out string moniker))
            {
                return(Events.FilterTeamEvents(level, moniker).Where(x => x.EventDate >= DateTime.Today));
            }

            return(null);
        }
        internal IEnumerable <TwinRinksEventConflict> GetGameConficts(string selectedTeam1, string selectedTeam2)
        {
            if (!string.IsNullOrWhiteSpace(selectedTeam1) && !string.IsNullOrWhiteSpace(selectedTeam2))
            {
                if (TwinRinksScheduleParserUtils.TryParseTeamLevelAndMoniker(selectedTeam1, out TwinRinksTeamLevel level1, out string moniker1))
                {
                    if (TwinRinksScheduleParserUtils.TryParseTeamLevelAndMoniker(selectedTeam2, out TwinRinksTeamLevel level2, out string moniker2))
                    {
                        TwinRinksEvent[] games = Events.Where(e => e.EventType == TwinRinksEventType.Game).ToArray();

                        IEnumerable <TwinRinksEvent> team1Games = games.FilterTeamEvents(level1, moniker1);
                        IEnumerable <TwinRinksEvent> team2Games = games.FilterTeamEvents(level2, moniker2);

                        return(team1Games.FindConflictsWith(team2Games));
                    }
                }
            }
            return(null);
        }
        internal byte[] GetICalFile(string team, IEnumerable <DateTime> dates)
        {
            if (TwinRinksScheduleParserUtils.TryParseTeamLevelAndMoniker(team, out TwinRinksTeamLevel level, out string moniker))
            {
                IEnumerable <TwinRinksEvent> events = Events.FilterTeamEvents(level, moniker);

                if (dates != null)
                {
                    HashSet <DateTime> dateFilter = new HashSet <DateTime>(dates);

                    events = events.Where(x => dates.Contains(x.EventDate));
                }

                string calValue = events.WriteICalFileString(team);

                return(Encoding.UTF8.GetBytes(calValue));
            }


            return(null);
        }
        internal byte[] GetTeamSnapScheduleImportFile(string team, IEnumerable <DateTime> dates)
        {
            if (TwinRinksScheduleParserUtils.TryParseTeamLevelAndMoniker(team, out TwinRinksTeamLevel level, out string moniker))
            {
                IEnumerable <TwinRinksEvent> events = Events.FilterTeamEvents(level, moniker);

                if (dates != null)
                {
                    HashSet <DateTime> dateFilter = new HashSet <DateTime>(dates);

                    events = events.Where(x => dateFilter.Contains(x.EventDate));
                }
                StringBuilder sb = new StringBuilder();

                using (StringWriter sw = new StringWriter(sb))
                {
                    events.WriteTeamSnapImportFile(sw);
                }

                return(ASCIIEncoding.ASCII.GetBytes(sb.ToString()));
            }

            return(null);
        }