Example #1
0
        /// <summary>
        /// Loads today's calendar event items for the user
        /// </summary>
        /// <returns></returns>
        public async Task <bool> LoadCalendarAsync()
        {
            LoggingViewModel.Instance.Information = string.Empty;
            try
            {
                //Clear out any calendar events added in previous calls to LoadCalendarAsync()
                if (TodaysEvents != null)
                {
                    TodaysEvents.Clear();
                }
                else
                {
                    TodaysEvents = new ObservableCollection <EventViewModel>();
                }

                //Get 24 hours worth of calendar events from Exchange service via API
                List <EventViewModel> events = await _calendarOperations.GetTodaysCalendar(6, 6);

                if (events.Count == 0)
                {
                    LoggingViewModel.Instance.Information = "You have no calendar events today.";
                }
                else
                {
                    //Load today's events into the observable collection that is bound to UI
                    foreach (EventViewModel calendarEvent in events)
                    {
                        TodaysEvents.Add(calendarEvent);
                    }
                }
            }
            catch (Exception ex)
            {
                LoggingViewModel.Instance.Information = "Error on load calender " + ex.Message;
                return(false);
            }
            return(true);
        }