public async Task <DialogTurnResult> ShowEventsSummary(WaterfallStepContext sc, CancellationToken cancellationToken = default(CancellationToken)) { try { var tokenResponse = sc.Result as TokenResponse; var state = await Accessor.GetAsync(sc.Context); if (state.SummaryEvents == null) { // this will lead to error when test if (string.IsNullOrEmpty(state.APIToken)) { return(await sc.EndDialogAsync(true)); } var calendarService = ServiceManager.InitCalendarService(state.APIToken, state.EventSource); var searchDate = TimeZoneInfo.ConvertTimeFromUtc(DateTime.UtcNow, state.GetUserTimeZone()); if (state.StartDate.Any()) { searchDate = state.StartDate.Last(); } var results = await GetEventsByTime(new List <DateTime>() { searchDate }, state.StartTime, state.EndDate, state.EndTime, state.GetUserTimeZone(), calendarService); var searchedEvents = new List <EventModel>(); bool searchTodayMeeting = state.StartDate.Any() && !state.StartTime.Any() && !state.EndDate.Any() && !state.EndTime.Any() && EventModel.IsSameDate(searchDate, TimeConverter.ConvertUtcToUserTime(DateTime.UtcNow, state.GetUserTimeZone())); foreach (var item in results) { if (!searchTodayMeeting || item.StartTime >= DateTime.UtcNow) { searchedEvents.Add(item); } } if (searchedEvents.Count == 0) { await sc.Context.SendActivityAsync(sc.Context.Activity.CreateReply(SummaryResponses.ShowNoMeetingMessage)); return(await sc.EndDialogAsync(true)); } else { var responseParams = new StringDictionary() { { "Count", searchedEvents.Count.ToString() }, { "EventName1", searchedEvents[0].Title }, { "EventDuration", searchedEvents[0].ToDurationString() }, }; if (searchedEvents.Count == 1) { await sc.Context.SendActivityAsync(sc.Context.Activity.CreateReply(SummaryResponses.ShowOneMeetingSummaryMessage, ResponseBuilder, responseParams)); } else { responseParams.Add("EventName2", searchedEvents[searchedEvents.Count - 1].Title); responseParams.Add("EventTime", SpeakHelper.ToSpeechMeetingTime(TimeConverter.ConvertUtcToUserTime(searchedEvents[searchedEvents.Count - 1].StartTime, state.GetUserTimeZone()), searchedEvents[searchedEvents.Count - 1].IsAllDay == true)); await sc.Context.SendActivityAsync(sc.Context.Activity.CreateReply(SummaryResponses.ShowMultipleMeetingSummaryMessage, ResponseBuilder, responseParams)); } } await ShowMeetingList(sc, searchedEvents.GetRange(0, Math.Min(CalendarSkillState.PageSize, searchedEvents.Count)), false); state.Clear(); state.SummaryEvents = searchedEvents; } else { await ShowMeetingList(sc, state.SummaryEvents.GetRange(state.ShowEventIndex *CalendarSkillState.PageSize, Math.Min(CalendarSkillState.PageSize, state.SummaryEvents.Count - (state.ShowEventIndex *CalendarSkillState.PageSize))), false); } return(await sc.NextAsync()); } catch { await HandleDialogExceptions(sc); throw; } }
/// <inheritdoc/> public async Task <EventModel> UpdateEventById(EventModel updateEvent) { return(await calendarAPI.UpdateEventById(updateEvent)); }
/// <inheritdoc/> public async Task <EventModel> CreateEvent(EventModel newEvent) { return(await calendarAPI.CreateEvent(newEvent)); }
/// <inheritdoc/> public async Task <EventModel> CreateEvent(EventModel newEvent) { await Task.CompletedTask; return(new EventModel(CreateEvent(newEvent.Value))); }
/// <inheritdoc/> public async Task <EventModel> UpdateEventById(EventModel updateEvent) { await Task.CompletedTask; return(new EventModel(UpdateEventById(updateEvent.Value))); }
/// <inheritdoc/> public async Task <EventModel> UpdateEventById(EventModel updateEvent) { return(new EventModel(await this.UpdateEvent(updateEvent.Value))); }