public async Task <SkillResponse> Handle(AlexaRequestInformation information) { var request = information.SkillRequest as APLSkillRequest; var id = ((IntentRequest)request.Request).Intent.Slots[Consts.SlotEvent].Id(); var currentDate = LocalDate.FromDateTime(DateTime.Now); var meetup = new TechMeetState { GroupName = id }; var rawEvents = await meetup.GetEventsFromS3(); var groupData = await meetup.GetGroupFromS3(); var events = rawEvents.ToLocalEventTime(); information.State.ClearSession(); information.State.SetSession(SessionKeys.CurrentActivity, SkillActivities.Event); information.State.SetSession(SessionKeys.CurrentGroup, id); if (!events.Any()) { return(SpeechHelper.NoEvent()); } var eventToRecognise = (events.Any(l => l.Date > currentDate) ? events.Where(e => e.Date > currentDate) : events).First(); information.State.SetSession(SessionKeys.CurrentEvent, eventToRecognise.Event.Id); return(await SpeechHelper.SingleEventResponse(request, eventToRecognise, currentDate, groupData, "I've got information on a meetup event. ")); }
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)); }