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();

            tre.AwayTeamName     = item.Away;
            tre.HomeTeamName     = item.Home;
            tre.Location         = ParseLocation(item);
            tre.Rink             = ParseRink(item);
            tre.EventType        = ParseEventType(item);
            tre.EventDescription = item.Description;
            tre.EventDate        = DateTime.Parse(item.Date);
            tre.EventEnd         = DateTime.Parse(item.End + "M").TimeOfDay;
            tre.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)
        {
            var rows = me.DocumentNode.SelectNodes("//td");

            int i = 0;

            TwinRinksParsedScheduleItem currItem = new TwinRinksParsedScheduleItem();

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

            foreach (var 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()));
        }