private static string ParseLocation(TwinRinksParsedScheduleItem parsed)
 {
     if (parsed.Location.StartsWith("AT "))
     {
         return(parsed.Location.Replace("AT ", ""));
     }
     else
     {
         return(parsed.Location);
     }
 }
 private static TwinRinksRink ParseRink(TwinRinksParsedScheduleItem item)
 {
     if (item.Rink.Equals("Blue"))
     {
         return(TwinRinksRink.Blue);
     }
     else if (item.Rink.Equals("Red"))
     {
         return(TwinRinksRink.Red);
     }
     else
     {
         return(TwinRinksRink.Away);
     }
 }
        public static TwinRinksEvent ToEvent(this TwinRinksParsedScheduleItem item)
        {
            TwinRinksEvent tre = new TwinRinksEvent
            {
                AwayTeamName     = item.Away,
                HomeTeamName     = item.Home,
                Location         = ParseLocation(item),
                Rink             = ParseRink(item),
                EventType        = ParseEventType(item),
                EventDescription = item.Description,
                EventDate        = DateTime.Parse(item.Date),
                EventEnd         = DateTime.Parse(item.End + "M").TimeOfDay,
                EventStart       = DateTime.Parse(item.Start + "M").TimeOfDay
            };

            return(tre);
        }
 private static TwinRinksEventType ParseEventType(TwinRinksParsedScheduleItem item)
 {
     return(item.Description.Contains("Game") ? TwinRinksEventType.Game : TwinRinksEventType.Practice);
 }
        public static IEnumerable <TwinRinksEvent> ParseTwinRinksEvents(this HtmlAgilityPack.HtmlDocument me)
        {
            HtmlAgilityPack.HtmlNodeCollection rows = me.DocumentNode.SelectNodes("//td");

            int i = 0;

            TwinRinksParsedScheduleItem currItem = new TwinRinksParsedScheduleItem();

            List <TwinRinksParsedScheduleItem> items = new List <TwinRinksParsedScheduleItem>();

            foreach (HtmlAgilityPack.HtmlNode r in rows)
            {
                switch (i)
                {
                case 0:

                    currItem.Date = r.InnerText.Trim();

                    break;

                case 1:

                    currItem.Day = r.InnerText.Trim();
                    break;

                case 2:
                    currItem.Rink = r.InnerText.Trim();

                    break;

                case 3:

                    currItem.Start = r.InnerText.Trim();
                    break;

                case 4:
                    currItem.End = r.InnerText.Trim();

                    break;

                case 5:

                    currItem.Location = r.InnerText.Trim();

                    break;

                case 6:

                    currItem.Description = r.InnerText.Trim();

                    break;

                case 7:

                    currItem.Home = r.InnerText.Trim();

                    break;

                case 8:

                    currItem.Away = r.InnerText.Trim();

                    break;
                }


                i++;

                if (i == 9)
                {
                    i = 0;

                    items.Add(currItem);

                    currItem = new TwinRinksParsedScheduleItem();
                }
            }

            return(items.Select(x => x.ToEvent()));
        }