/// <summary>
        /// Updates the specified AdministrativeUnit using PATCH.
        /// </summary>
        /// <param name="administrativeUnitToUpdate">The AdministrativeUnit 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 AdministrativeUnit.</returns>
        public async System.Threading.Tasks.Task <AdministrativeUnit> UpdateAsync(AdministrativeUnit administrativeUnitToUpdate, CancellationToken cancellationToken)
        {
            if (administrativeUnitToUpdate.AdditionalData != null)
            {
                if (administrativeUnitToUpdate.AdditionalData.ContainsKey(Constants.HttpPropertyNames.ResponseHeaders) ||
                    administrativeUnitToUpdate.AdditionalData.ContainsKey(Constants.HttpPropertyNames.StatusCode))
                {
                    throw new ClientException(
                              new Error
                    {
                        Code    = GeneratedErrorConstants.Codes.NotAllowed,
                        Message = String.Format(GeneratedErrorConstants.Messages.ResponseObjectUsedForUpdate, administrativeUnitToUpdate.GetType().Name)
                    });
                }
            }
            if (administrativeUnitToUpdate.AdditionalData != null)
            {
                if (administrativeUnitToUpdate.AdditionalData.ContainsKey(Constants.HttpPropertyNames.ResponseHeaders) ||
                    administrativeUnitToUpdate.AdditionalData.ContainsKey(Constants.HttpPropertyNames.StatusCode))
                {
                    throw new ClientException(
                              new Error
                    {
                        Code    = GeneratedErrorConstants.Codes.NotAllowed,
                        Message = String.Format(GeneratedErrorConstants.Messages.ResponseObjectUsedForUpdate, administrativeUnitToUpdate.GetType().Name)
                    });
                }
            }
            this.ContentType = "application/json";
            this.Method      = "PATCH";
            var updatedEntity = await this.SendAsync <AdministrativeUnit>(administrativeUnitToUpdate, cancellationToken).ConfigureAwait(false);

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

            return(newEntity);
        }
        /// <summary>
        /// Updates the specified AdministrativeUnit using PATCH.
        /// </summary>
        /// <param name="administrativeUnitToUpdate">The AdministrativeUnit to update.</param>
        /// <param name="cancellationToken">The <see cref="CancellationToken"/> for the request.</param>
        /// <returns>The updated AdministrativeUnit.</returns>
        public async System.Threading.Tasks.Task <AdministrativeUnit> UpdateAsync(AdministrativeUnit administrativeUnitToUpdate, CancellationToken cancellationToken)
        {
            this.ContentType = "application/json";
            this.Method      = "PATCH";
            var updatedEntity = await this.SendAsync <AdministrativeUnit>(administrativeUnitToUpdate, cancellationToken).ConfigureAwait(false);

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

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

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

                if (administrativeUnitToInitialize.ScopedRoleMembers != null && administrativeUnitToInitialize.ScopedRoleMembers.CurrentPage != null)
                {
                    administrativeUnitToInitialize.ScopedRoleMembers.AdditionalData = administrativeUnitToInitialize.AdditionalData;

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

                    if (!string.IsNullOrEmpty(nextPageLinkString))
                    {
                        administrativeUnitToInitialize.ScopedRoleMembers.InitializeNextPageRequest(
                            this.Client,
                            nextPageLinkString);
                    }
                }

                if (administrativeUnitToInitialize.Extensions != null && administrativeUnitToInitialize.Extensions.CurrentPage != null)
                {
                    administrativeUnitToInitialize.Extensions.AdditionalData = administrativeUnitToInitialize.AdditionalData;

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

                    if (!string.IsNullOrEmpty(nextPageLinkString))
                    {
                        administrativeUnitToInitialize.Extensions.InitializeNextPageRequest(
                            this.Client,
                            nextPageLinkString);
                    }
                }
            }
        }
Esempio n. 5
0
 /// <summary>
 /// Adds the specified AdministrativeUnit to the collection via POST.
 /// </summary>
 /// <param name="administrativeUnit">The AdministrativeUnit to add.</param>
 /// <param name="cancellationToken">The <see cref="CancellationToken"/> for the request.</param>
 /// <returns>The created AdministrativeUnit.</returns>
 public System.Threading.Tasks.Task <AdministrativeUnit> AddAsync(AdministrativeUnit administrativeUnit, CancellationToken cancellationToken)
 {
     this.ContentType = "application/json";
     this.Method      = "POST";
     return(this.SendAsync <AdministrativeUnit>(administrativeUnit, cancellationToken));
 }
Esempio n. 6
0
 /// <summary>
 /// Adds the specified AdministrativeUnit to the collection via POST.
 /// </summary>
 /// <param name="administrativeUnit">The AdministrativeUnit to add.</param>
 /// <returns>The created AdministrativeUnit.</returns>
 public System.Threading.Tasks.Task <AdministrativeUnit> AddAsync(AdministrativeUnit administrativeUnit)
 {
     return(this.AddAsync(administrativeUnit, CancellationToken.None));
 }
 /// <summary>
 /// Updates the specified AdministrativeUnit using PATCH.
 /// </summary>
 /// <param name="administrativeUnitToUpdate">The AdministrativeUnit to update.</param>
 /// <returns>The updated AdministrativeUnit.</returns>
 public System.Threading.Tasks.Task <AdministrativeUnit> UpdateAsync(AdministrativeUnit administrativeUnitToUpdate)
 {
     return(this.UpdateAsync(administrativeUnitToUpdate, CancellationToken.None));
 }
Esempio n. 8
0
 /// <summary>
 /// Initializes any collection properties after deserialization, like next requests for paging.
 /// </summary>
 /// <param name="administrativeUnitToInitialize">The <see cref="AdministrativeUnit"/> with the collection properties to initialize.</param>
 private void InitializeCollectionProperties(AdministrativeUnit administrativeUnitToInitialize)
 {
 }