Esempio n. 1
0
        /// <summary>
        /// Updates the specified PlannerRoster using PATCH.
        /// </summary>
        /// <param name="plannerRosterToUpdate">The PlannerRoster to update.</param>
        /// <param name="cancellationToken">The <see cref="CancellationToken"/> for the request.</param>
        /// <exception cref="ClientException">Thrown when an object returned in a response is used for updating an object in Microsoft Graph.</exception>
        /// <returns>The updated PlannerRoster.</returns>
        public async System.Threading.Tasks.Task <PlannerRoster> UpdateAsync(PlannerRoster plannerRosterToUpdate, CancellationToken cancellationToken)
        {
            if (plannerRosterToUpdate.AdditionalData != null)
            {
                if (plannerRosterToUpdate.AdditionalData.ContainsKey(Constants.HttpPropertyNames.ResponseHeaders) ||
                    plannerRosterToUpdate.AdditionalData.ContainsKey(Constants.HttpPropertyNames.StatusCode))
                {
                    throw new ClientException(
                              new Error
                    {
                        Code    = GeneratedErrorConstants.Codes.NotAllowed,
                        Message = String.Format(GeneratedErrorConstants.Messages.ResponseObjectUsedForUpdate, plannerRosterToUpdate.GetType().Name)
                    });
                }
            }
            if (plannerRosterToUpdate.AdditionalData != null)
            {
                if (plannerRosterToUpdate.AdditionalData.ContainsKey(Constants.HttpPropertyNames.ResponseHeaders) ||
                    plannerRosterToUpdate.AdditionalData.ContainsKey(Constants.HttpPropertyNames.StatusCode))
                {
                    throw new ClientException(
                              new Error
                    {
                        Code    = GeneratedErrorConstants.Codes.NotAllowed,
                        Message = String.Format(GeneratedErrorConstants.Messages.ResponseObjectUsedForUpdate, plannerRosterToUpdate.GetType().Name)
                    });
                }
            }
            this.ContentType = "application/json";
            this.Method      = "PATCH";
            var updatedEntity = await this.SendAsync <PlannerRoster>(plannerRosterToUpdate, cancellationToken).ConfigureAwait(false);

            this.InitializeCollectionProperties(updatedEntity);
            return(updatedEntity);
        }
Esempio n. 2
0
        /// <summary>
        /// Creates the specified PlannerRoster using POST.
        /// </summary>
        /// <param name="plannerRosterToCreate">The PlannerRoster to create.</param>
        /// <param name="cancellationToken">The <see cref="CancellationToken"/> for the request.</param>
        /// <returns>The created PlannerRoster.</returns>
        public async System.Threading.Tasks.Task <PlannerRoster> CreateAsync(PlannerRoster plannerRosterToCreate, CancellationToken cancellationToken)
        {
            this.ContentType = "application/json";
            this.Method      = "POST";
            var newEntity = await this.SendAsync <PlannerRoster>(plannerRosterToCreate, cancellationToken).ConfigureAwait(false);

            this.InitializeCollectionProperties(newEntity);
            return(newEntity);
        }
Esempio n. 3
0
        /// <summary>
        /// Initializes any collection properties after deserialization, like next requests for paging.
        /// </summary>
        /// <param name="plannerRosterToInitialize">The <see cref="PlannerRoster"/> with the collection properties to initialize.</param>
        private void InitializeCollectionProperties(PlannerRoster plannerRosterToInitialize)
        {
            if (plannerRosterToInitialize != null && plannerRosterToInitialize.AdditionalData != null)
            {
                if (plannerRosterToInitialize.Members != null && plannerRosterToInitialize.Members.CurrentPage != null)
                {
                    plannerRosterToInitialize.Members.AdditionalData = plannerRosterToInitialize.AdditionalData;

                    object nextPageLink;
                    plannerRosterToInitialize.AdditionalData.TryGetValue("*****@*****.**", out nextPageLink);
                    var nextPageLinkString = nextPageLink as string;

                    if (!string.IsNullOrEmpty(nextPageLinkString))
                    {
                        plannerRosterToInitialize.Members.InitializeNextPageRequest(
                            this.Client,
                            nextPageLinkString);
                    }
                }

                if (plannerRosterToInitialize.Plans != null && plannerRosterToInitialize.Plans.CurrentPage != null)
                {
                    plannerRosterToInitialize.Plans.AdditionalData = plannerRosterToInitialize.AdditionalData;

                    object nextPageLink;
                    plannerRosterToInitialize.AdditionalData.TryGetValue("*****@*****.**", out nextPageLink);
                    var nextPageLinkString = nextPageLink as string;

                    if (!string.IsNullOrEmpty(nextPageLinkString))
                    {
                        plannerRosterToInitialize.Plans.InitializeNextPageRequest(
                            this.Client,
                            nextPageLinkString);
                    }
                }
            }
        }
Esempio n. 4
0
 /// <summary>
 /// Creates the specified PlannerRoster using POST.
 /// </summary>
 /// <param name="plannerRosterToCreate">The PlannerRoster to create.</param>
 /// <returns>The created PlannerRoster.</returns>
 public System.Threading.Tasks.Task <PlannerRoster> CreateAsync(PlannerRoster plannerRosterToCreate)
 {
     return(this.CreateAsync(plannerRosterToCreate, CancellationToken.None));
 }
Esempio n. 5
0
 /// <summary>
 /// Adds the specified PlannerRoster to the collection via POST.
 /// </summary>
 /// <param name="plannerRoster">The PlannerRoster to add.</param>
 /// <param name="cancellationToken">The <see cref="CancellationToken"/> for the request.</param>
 /// <returns>The created PlannerRoster.</returns>
 public System.Threading.Tasks.Task <PlannerRoster> AddAsync(PlannerRoster plannerRoster, CancellationToken cancellationToken)
 {
     this.ContentType = "application/json";
     this.Method      = "POST";
     return(this.SendAsync <PlannerRoster>(plannerRoster, cancellationToken));
 }
Esempio n. 6
0
 /// <summary>
 /// Adds the specified PlannerRoster to the collection via POST.
 /// </summary>
 /// <param name="plannerRoster">The PlannerRoster to add.</param>
 /// <returns>The created PlannerRoster.</returns>
 public System.Threading.Tasks.Task <PlannerRoster> AddAsync(PlannerRoster plannerRoster)
 {
     return(this.AddAsync(plannerRoster, CancellationToken.None));
 }