protected void Page_Load(object sender, EventArgs e) { _CalendarAbsPath = MapPath("~/Calendars"); if (!IsPostBack) { // Load our list of available calendars CalendarList.DataSource = LoadCalendarList(); CalendarList.DataBind(); // Select all calendars in the list by default foreach (ListItem li in CalendarList.Items) { li.Selected = true; } } // Get a list of todays events and upcoming events List <Occurrence> todaysEvents = GetTodaysEvents(); List <Occurrence> upcomingEvents = GetUpcomingEvents(); // Bind our list to the repeater that will display the events. TodaysEvents.DataSource = todaysEvents; TodaysEvents.DataBind(); // Bind our list to the repeater that will display the events. UpcomingEvents.DataSource = upcomingEvents; UpcomingEvents.DataBind(); }
/// <summary> /// Sends event remove request to Exchange service /// </summary> async void ExecuteDeleteCommandAsync() { try { if (await MessageDialogHelper.ShowYesNoDialogAsync(String.Format("Are you sure you want to delete the event '{0}'?", this._selectedEvent.DisplayString), "Confirm Deletion")) { if (!String.IsNullOrEmpty(this._selectedEvent.Id)) { await _calendarOperations.DeleteCalendarEventAsync(this._selectedEvent.Id); } //Removes event from bound observable collection TodaysEvents.Remove((EventViewModel)_selectedEvent); } } catch (Exception) { LoggingViewModel.Instance.Information = "We could not delete your calendar event"; } }
protected void Page_Load(object sender, EventArgs e) { _CalendarAbsPath = MapPath("~/Calendars"); if (!IsPostBack) { // Load our list of available calendars CalendarList.DataSource = LoadCalendarList(); CalendarList.DataBind(); // Select all calendars in the list by default foreach (ListItem li in CalendarList.Items) { li.Selected = true; } } // Create an object that will sort our events by date EventDateSorter eventDateSorter = new EventDateSorter(); // Build a list of today's events List <Event> todaysEvents = new List <Event>(GetTodaysEvents()); // Sort our list by start date todaysEvents.Sort(eventDateSorter); // Bind our list to the repeater that will display the events. TodaysEvents.DataSource = todaysEvents; TodaysEvents.DataBind(); // Build a list of upcoming events List <Event> upcomingEvents = new List <Event>(GetUpcomingEvents()); // Sort that list by start date upcomingEvents.Sort(eventDateSorter); // Bind our list to the repeater that will display the events. UpcomingEvents.DataSource = upcomingEvents; UpcomingEvents.DataBind(); }
/// <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); }