/// <summary>
 /// Initializes the NextPageRequest property.
 /// </summary>
 public void InitializeNextPageRequest(IBaseClient client, string nextPageLinkString)
 {
     if (!string.IsNullOrEmpty(nextPageLinkString))
     {
         this.NextPageRequest = new UserEventsCollectionRequest(
             nextPageLinkString,
             client,
             null);
     }
 }
Beispiel #2
0
        /// <summary>
        /// retrieve the next page of events
        /// </summary>
        /// <param name="cancellationToken">The <see cref="CancellationToken"/> for the request.</param>
        /// <returns>the next collection of messages or null if there are no more messages</returns>
        public async Task <IUserEventsCollectionPage> NextPageEventsAsync(CancellationToken cancellationToken)
        {
            if (_nextPageRequest != null)
            {
                var events = await _nextPageRequest.GetAsync(cancellationToken);

                _nextPageRequest = events.NextPageRequest;
                return(events);
            }

            // no more messages
            return(null);
        }
Beispiel #3
0
        /// <summary>
        /// Retrieve current connected user's events.
        /// <para>(default=10)</para>
        /// <para>Permission Scope : Event.Read (Read user calendar)</para>
        /// </summary>
        /// <param name="cancellationToken">The <see cref="CancellationToken"/> for the request.</param>
        /// <param name="top">The number of items to return in a result set.</param>
        /// <param name="selectFields">array of fields Microsoft Graph has to include in the response.</param>
        /// <returns>a Collection of Pages containing the events</returns>
        public async Task <IUserEventsCollectionPage> GetEventsAsync(CancellationToken cancellationToken, int top = 10, MicrosoftGraphEventFields[] selectFields = null)
        {
            IUserEventsCollectionPage events = null;

            if (selectFields == null)
            {
                events = await _graphProvider.Me.Events.Request().OrderBy(OrderBy).Top(top).GetAsync(cancellationToken);
            }
            else
            {
                string selectedProperties = MicrosoftGraphHelper.BuildString(selectFields);
                events = await _graphProvider.Me.Events.Request().OrderBy(OrderBy).Top(top).Select(selectedProperties).GetAsync();
            }

            _nextPageRequest = events.NextPageRequest;
            return(events);
        }
        public static async Task <Event[]> GetAllAsync(this IUserEventsCollectionRequest pagedCollectionRq)
        {
            var list = new List <Event>();
            var collectionRequest = pagedCollectionRq;

            while (true && collectionRequest != null)
            {
                var pageList = await collectionRequest.GetAsync();

                if (pageList.CurrentPage.Count > 0)
                {
                    list.AddRange(pageList.CurrentPage);
                    collectionRequest = pageList.NextPageRequest;
                }
                else
                {
                    break;
                }
            }
            return(list.ToArray());
        }