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 CalendarEvent BuildCalendarEvent(TwinRinksEvent evt, string title)
        {
            var vEvent = new CalendarEvent();

            vEvent.Location = $"Twin Rinks - {evt.Rink} Rink";
            vEvent.Created  = new CalDateTime(DateTime.Now);
            vEvent.Class    = "PUBLIC";

            if (evt.EventType == TwinRinksEventType.Game)
            {
                if (evt.Rink == TwinRinksRink.Away)
                {
                    vEvent.Summary  = $"{title}: Away Game vs {evt.AwayTeamName}@{evt.Location}";
                    vEvent.Location = evt.Location;
                }
                else
                {
                    vEvent.Summary = $"{title}: Home Game vs {evt.AwayTeamName}@{evt.Rink} Rink";
                }
            }
            else
            {
                if (evt.IsPowerSkatingEvent())
                {
                    vEvent.Summary = $"{title}: Power Skating@{evt.Rink} Rink";
                }

                else
                {
                    vEvent.Summary = $"{title}: Practice@{evt.Rink} Rink";
                }
            }

            var startDate = evt.EventDate.Add(evt.EventStart);

            var endDate = evt.EventDate.Add(evt.EventEnd);

            vEvent.Start = new CalDateTime(startDate, "America/Chicago");

            vEvent.End = new CalDateTime(endDate, "America/Chicago");

            return(vEvent);
        }
 public static bool IsPowerSkatingEvent(this TwinRinksEvent evt)
 {
     return(evt.HomeTeamName.EndsWith(" POW") || evt.HomeTeamName.EndsWith(" P") || evt.HomeTeamName.EndsWith(" POWER") ||
            evt.AwayTeamName.EndsWith(" POW") || evt.AwayTeamName.EndsWith(" P") || evt.AwayTeamName.EndsWith(" POWER"));
 }
        public static bool IsDifferentFrom(this TwinRinksEvent me, TwinRinksEvent other, out HashSet <TwinRinksEventField> whichFields)
        {
            if (me == null)
            {
                throw new ArgumentNullException(nameof(me));
            }

            if (other == null)
            {
                throw new ArgumentNullException(nameof(other));
            }


            bool res = false;

            whichFields = new HashSet <TwinRinksEventField>();

            if (!me.AwayTeamName.Equals(other.AwayTeamName, StringComparison.InvariantCultureIgnoreCase))
            {
                res = true;

                whichFields.Add(TwinRinksEventField.AwayTeamName);
            }

            if (me.EventDate != other.EventDate)
            {
                res = true;

                whichFields.Add(TwinRinksEventField.EventDate);
            }


            if (me.EventDescription != other.EventDescription)
            {
                res = true;

                whichFields.Add(TwinRinksEventField.EventDescription);
            }


            if (me.EventEnd != other.EventEnd)
            {
                res = true;

                whichFields.Add(TwinRinksEventField.EventEnd);
            }

            if (me.EventStart != other.EventStart)
            {
                res = true;

                whichFields.Add(TwinRinksEventField.EventStart);
            }

            if (me.EventType != other.EventType)
            {
                res = true;

                whichFields.Add(TwinRinksEventField.EventType);
            }

            if (!me.HomeTeamName.Equals(other.HomeTeamName))
            {
                res = true;

                whichFields.Add(TwinRinksEventField.HomeTeamName);
            }


            if (!me.Location.Equals(other.Location))
            {
                res = true;

                whichFields.Add(TwinRinksEventField.Location);
            }


            if (me.Rink != other.Rink)
            {
                res = true;

                whichFields.Add(TwinRinksEventField.Rink);
            }

            return(res);
        }
 public static string GenerateIdentifier(this TwinRinksEvent me)
 {
     return(Sha1Hash(me.ToString()));
 }