Пример #1
0
        /// <summary>
        /// Gets the details of an event.
        /// </summary>
        /// <param name="SelectedEventId">string. The unique identifier of an event selected in the UI.</param>
        /// <returns>A calendar event.</returns>
        internal async Task <model.CalendarEvent> GetEventDetailsAsync(string SelectedEventId)
        {
            // Make sure we have a reference to the Outlook Services client
            var outlookServicesClient = await AuthenticationHelper.EnsureOutlookServicesClientCreatedAsync("Calendar");

            // This results in a call to the service.
            var thisEventFetcher = outlookServicesClient.Me.Calendar.Events.GetById(SelectedEventId);
            var thisEvent        = await thisEventFetcher.ExecuteAsync();

            model.CalendarEvent modelEvent = new model.CalendarEvent(thisEvent);
            return(modelEvent);
        }
        /// <summary>
        /// Gets the details of an event.
        /// </summary>
        /// <param name="SelectedEventId">string. The unique identifier of an event selected in the UI.</param>
        /// <returns>A calendar event.</returns>
        internal async Task<model.CalendarEvent> GetEventDetailsAsync(string SelectedEventId)
        {

            // Make sure we have a reference to the Outlook Services client
            var outlookServicesClient = await AuthenticationHelper.EnsureOutlookServicesClientCreatedAsync("Calendar");

            // This results in a call to the service.
            var thisEventFetcher = outlookServicesClient.Me.Calendar.Events.GetById(SelectedEventId);
            var thisEvent = await thisEventFetcher.ExecuteAsync();
            model.CalendarEvent modelEvent = new model.CalendarEvent(thisEvent);
            return modelEvent;
        }
        /// <summary>
        /// Gets a collection of events for a specified time span.
        /// </summary>
        /// <param name="hoursBefore">int. The beginning of the TimeSpan that defines which events are returned.</param>
        /// <param name="hoursAfter">int. The end of the TimeSpan that defines which events are returned.</param>
        /// <returns>A collection of all calendar events found for the specified time range.</returns>
        internal async Task<List<model.CalendarEvent>> GetTodaysCalendar(int hoursBefore, int hoursAfter, int pageNo, int pageSize)
        {
            // Make sure we have a reference to the Outlook Services client
            var outlookServicesClient = await AuthenticationHelper.EnsureOutlookServicesClientCreatedAsync("Calendar");

            List<model.CalendarEvent> returnResults = new List<model.CalendarEvent>();

            var eventsResults = await (from i in outlookServicesClient.Me.Calendar.Events
                                       where i.Start >= DateTimeOffset.Now.Subtract(new TimeSpan(hoursBefore, 0, 0)) &&
                                       i.Start <= DateTimeOffset.Now.AddHours(hoursAfter)
                                       orderby i.Start
                                       select i).Skip((pageNo - 1) * pageSize).Take(pageSize).ExecuteAsync();



            var events = eventsResults.CurrentPage;

            foreach (IEvent serverEvent in events)
            {

                //model.CalendarEvent modelEvent = await GetEventDetailsAsync(ctx, serverEvent.Id);
                model.CalendarEvent modelEvent = new model.CalendarEvent(serverEvent);
                if ((!eventsResults.MorePagesAvailable))
                {
                    if (modelEvent.ID == events.Last<IEvent>().Id)
                    {
                        modelEvent.IsLastItem = true;

                    }
                }
                if ((modelEvent.ID == events.First<IEvent>().Id) && pageNo == 1)
                {
                    modelEvent.IsFirstItem = true;
                }

                returnResults.Add(modelEvent);
            }


            return returnResults;
        }
Пример #4
0
        /// <summary>
        /// Gets a collection of events for a specified time span.
        /// </summary>
        /// <param name="hoursBefore">int. The beginning of the TimeSpan that defines which events are returned.</param>
        /// <param name="hoursAfter">int. The end of the TimeSpan that defines which events are returned.</param>
        /// <returns>A collection of all calendar events found for the specified time range.</returns>
        internal async Task <List <model.CalendarEvent> > GetTodaysCalendar(int hoursBefore, int hoursAfter, int pageNo, int pageSize)
        {
            // Make sure we have a reference to the Outlook Services client
            var outlookServicesClient = await AuthenticationHelper.EnsureOutlookServicesClientCreatedAsync("Calendar");

            List <model.CalendarEvent> returnResults = new List <model.CalendarEvent>();

            var eventsResults = await(from i in outlookServicesClient.Me.Calendar.Events
                                      where i.Start >= DateTimeOffset.Now.Subtract(new TimeSpan(hoursBefore, 0, 0)) &&
                                      i.Start <= DateTimeOffset.Now.AddHours(hoursAfter)
                                      orderby i.Start
                                      select i).Skip((pageNo - 1) * pageSize).Take(pageSize).ExecuteAsync();



            var events = eventsResults.CurrentPage;

            foreach (IEvent serverEvent in events)
            {
                //model.CalendarEvent modelEvent = await GetEventDetailsAsync(ctx, serverEvent.Id);
                model.CalendarEvent modelEvent = new model.CalendarEvent(serverEvent);
                if ((!eventsResults.MorePagesAvailable))
                {
                    if (modelEvent.ID == events.Last <IEvent>().Id)
                    {
                        modelEvent.IsLastItem = true;
                    }
                }
                if ((modelEvent.ID == events.First <IEvent>().Id) && pageNo == 1)
                {
                    modelEvent.IsFirstItem = true;
                }

                returnResults.Add(modelEvent);
            }


            return(returnResults);
        }
Пример #5
0
        //
        // GET: /Calendar/Delete/5
        public async Task <ActionResult> Delete(string id)
        {
            model.CalendarEvent deletedEvent = await _calenderOperations.GetEventDetailsAsync(id);

            return(View(deletedEvent));
        }
Пример #6
0
        //
        // GET: /Calendar/Edit/5
        public async Task <ActionResult> Edit(string id, int page)
        {
            model.CalendarEvent eventToUpdate = await _calenderOperations.GetEventDetailsAsync(id);

            return(View(eventToUpdate));
        }