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

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

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

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

                    if (!string.IsNullOrEmpty(nextPageLinkString))
                    {
                        custodianToInitialize.SiteSources.InitializeNextPageRequest(
                            this.Client,
                            nextPageLinkString);
                    }
                }

                if (custodianToInitialize.UnifiedGroupSources != null && custodianToInitialize.UnifiedGroupSources.CurrentPage != null)
                {
                    custodianToInitialize.UnifiedGroupSources.AdditionalData = custodianToInitialize.AdditionalData;

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

                    if (!string.IsNullOrEmpty(nextPageLinkString))
                    {
                        custodianToInitialize.UnifiedGroupSources.InitializeNextPageRequest(
                            this.Client,
                            nextPageLinkString);
                    }
                }

                if (custodianToInitialize.UserSources != null && custodianToInitialize.UserSources.CurrentPage != null)
                {
                    custodianToInitialize.UserSources.AdditionalData = custodianToInitialize.AdditionalData;

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

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