Beispiel #1
0
        public async Task <SkillResponse> Handle(AlexaRequestInformation information)
        {
            information.State.ClearSession();
            var intent = ((IntentRequest)information.SkillRequest.Request).Intent;

            var dates       = AmazonDateParser.Parse(intent.Slots[Consts.SlotDateRange].Value);
            var currentDate = LocalDate.FromDateTime(DateTime.Now);
            var id          = intent.Slots[Consts.SlotEvent].Id();

            var meetup = new TechMeetState {
                GroupName = id
            };

            var rawEvents = await meetup.GetEventsFromS3();

            var groupData = await meetup.GetGroupFromS3();

            information.State.SetSession(SessionKeys.CurrentActivity, SkillActivities.Event);
            information.State.SetSession(SessionKeys.CurrentGroup, id);

            var eventToRecognise = rawEvents.ToLocalEventTime()
                                   .Where(d => d.Date >= dates.From && d.Date <= dates.To).Where(d => d.Date >= currentDate).ToArray();

            if (!eventToRecognise.Any())
            {
                return(SpeechHelper.NoEvent(true));
            }

            if (eventToRecognise.Length == 1)
            {
                return(await SpeechHelper.SingleEventResponse((APLSkillRequest)information.SkillRequest, eventToRecognise.First(), currentDate, groupData, "I've got information on a meetup event. "));
            }

            return(SpeechHelper.RespondToEvent(eventToRecognise, currentDate, groupData.Name));
        }
Beispiel #2
0
        public async Task <SkillResponse> Handle(AlexaRequestInformation information)
        {
            information.State.ClearSession();
            var currentDate = LocalDate.FromDateTime(DateTime.Now);

            var meetupTasks = Meetups.Select(m => new TechMeetState {
                GroupName = m
            }.GetEventsFromS3());
            var rawEvents = (await Task.WhenAll(meetupTasks)).SelectMany(t => t).ToLocalEventTime().Where(d => d.Date >= currentDate);

            var eventToRecognise = rawEvents.Where(l => l.Date < currentDate.PlusDays(14)).OrderBy(l => l.Date).ToArray();

            if (!eventToRecognise.Any())
            {
                return(SpeechHelper.NoEvent(true));
            }

            return(SpeechHelper.RespondToEvent(eventToRecognise, currentDate));
        }
        public async Task <SkillResponse> Handle(AlexaRequestInformation information)
        {
            information.State.ClearSession();
            var intent = ((IntentRequest)information.SkillRequest.Request).Intent;

            var dates       = AmazonDateParser.Parse(intent.Slots[Consts.SlotDateRange].Value);
            var currentDate = LocalDate.FromDateTime(DateTime.Now);

            var meetupTasks = Meetups.Select(m => new TechMeetState {
                GroupName = m
            }.GetEventsFromS3());
            var rawEvents = (await Task.WhenAll(meetupTasks)).SelectMany(t => t).ToLocalEventTime()
                            .Where(d => d.Date >= dates.From && d.Date <= dates.To);

            var eventToRecognise = rawEvents.OrderBy(l => l.Date).Where(d => d.Date >= currentDate).ToArray();

            if (!eventToRecognise.Any())
            {
                return(SpeechHelper.NoEvent(true));
            }

            return(SpeechHelper.RespondToEvent(eventToRecognise, currentDate));
        }