/// <summary> /// Gets a collection of calendar events. /// </summary> /// <returns>A collection of all calendar events.</returns> internal async Task<List<EventViewModel>> GetCalendarEventsAsync() { // Make sure we have a reference to the Exchange client var exchangeClient = await AuthenticationHelper.EnsureOutlookClientCreatedAsync(); List<EventViewModel> returnResults = new List<EventViewModel>(); var eventsResults = await exchangeClient.Me.Calendar.Events.OrderBy(e => e.Start).ExecuteAsync(); foreach (IEvent calendarEvent in eventsResults.CurrentPage) { IEvent thisEvent = await GetEventDetailsAsync( calendarEvent.Id); EventViewModel calendarEventModel = new EventViewModel(thisEvent); returnResults.Add(calendarEventModel); } return returnResults; }
/// <summary> /// Creates a new event and adds it to the collection. /// </summary> /// <remarks>The event is created locally.</remarks> async void ExecuteNewEventCommandAsync() { var aadClient = await AuthenticationHelper.EnsureGraphClientCreatedAsync(); var currentUser = await (aadClient.Users .Where(i => i.ObjectId == AuthenticationHelper.LoggedInUser) .ExecuteSingleAsync()); var newEvent = new EventViewModel(currentUser.Mail); this.Events.Add(newEvent); this.SelectedEvent = newEvent; LoggingViewModel.Instance.Information = "Click the Update Event button and we'll save the new event to your calendar"; }