Example #1
0
        public void OnGet(string SelectedTeam)
        {
            SelectedTeam = EnsureCookie(SelectedTeam);

            Teams = new SelectList(new[] { "Select Team" }.Union(_twinRinksService.GetTeamsList()).ToArray());

            this.SelectedTeam = SelectedTeam;

            Events = _twinRinksService.GetEvents(SelectedTeam);
        }
        public WeeklyScheduleResult[] GetSchedule(string team)
        {
            if (team == null)
            {
                throw new ArgumentException(nameof(team));
            }

            ConcurrentDictionary <int, List <TwinRinksEvent> > eventsByWeek = new ConcurrentDictionary <int, List <TwinRinksEvent> >();

            foreach (var e in _twinRinksService.GetEvents(team).Select(x => new { Week = x.EventDate.GetIso8601WeekOfYear(), Event = x }))
            {
                eventsByWeek.AddOrUpdate(e.Week, (i) => new List <TwinRinksEvent>()
                {
                    e.Event
                }, (i, l) => { l.Add(e.Event); return(l); });
            }

            return(eventsByWeek.OrderBy(x => x.Key).Select(x => new WeeklyScheduleResult()
            {
                Events = x.Value.Select(e => new EventResult(e)).ToList()
            }).ToArray());
        }
        private SkillResponse ProcessListEventsRequest(IntentRequest request, bool listEvents = true)
        {
            EventType evtType = ExtractEventType(request.Intent.Slots["eventType"]);

            AmazonDateParser.DateRange range = ExtractDateRange(request.Intent.Slots["eventHorizon"]);

            if (string.IsNullOrWhiteSpace(request.Intent.Slots["teamname"].Value))
            {
                return(SayTeamNotFound(null));
            }

            string utteredTeamName = request.Intent.Slots["teamname"].Value.ToUpperInvariant();

            string resolvedTeamName = FuzzyFindTeam(parserService.GetTeamsList(), utteredTeamName)?.ToLowerInvariant();

            if (!string.IsNullOrWhiteSpace(resolvedTeamName))
            {
                System.Collections.Generic.IEnumerable <TwinRinks.YH.ScheduleParser.TwinRinksEvent> candidateEvents = parserService.GetEvents(resolvedTeamName).Where(x => (x.EventDate + x.EventStart) > range.Start && (x.EventDate + x.EventStart) < range.End);

                if (evtType == EventType.Practice)
                {
                    candidateEvents = candidateEvents.Where(x => x.EventType == TwinRinksEventType.Practice);
                }
                else if (evtType == EventType.Power)
                {
                    candidateEvents = candidateEvents.Where(x => x.IsPowerSkatingEvent());
                }
                else if (evtType == EventType.Game)
                {
                    candidateEvents = candidateEvents.Where(x => x.EventType == TwinRinksEventType.Game);
                }
                if (listEvents)
                {
                    return(BuildEventListRespose(candidateEvents, resolvedTeamName));
                }
                else
                {
                    return(BuildEventQuestionRespose(candidateEvents, resolvedTeamName));
                }
            }
            else
            {
                return(SayTeamNotFound(utteredTeamName));
            }
        }