public TwinRinksEventKey(TwinRinksEvent evt) { if (evt == null) { throw new ArgumentNullException(nameof(evt)); } EventStartDate = evt.EventDate + evt.EventStart; EventType = evt.EventType; Location = evt.Location; }
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 CalendarEvent BuildCalendarEvent(TwinRinksEvent evt) { CalendarEvent vEvent = new CalendarEvent { Location = $"Twin Rinks - {evt.Rink} Rink", Created = new CalDateTime(DateTime.Now), Class = "PUBLIC" }; if (evt.EventType == TwinRinksEventType.Game) { if (evt.Rink == TwinRinksRink.Away) { vEvent.Summary = $"Away Game vs {evt.AwayTeamName}@{evt.Location}"; vEvent.Location = evt.Location; } else { vEvent.Summary = $"Home Game vs {evt.AwayTeamName}@{evt.Rink} Rink"; } } else { if (evt.IsPowerSkatingEvent()) { vEvent.Summary = $"Power Skating@{evt.Rink} Rink"; } else { vEvent.Summary = $"Practice@{evt.Rink} Rink"; } } DateTime startDate = evt.EventDate.Add(evt.EventStart); DateTime 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, StringComparison.InvariantCultureIgnoreCase)) { res = true; whichFields.Add(TwinRinksEventField.HomeTeamName); } if (!me.Location.Equals(other.Location, StringComparison.InvariantCultureIgnoreCase)) { 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())); }