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

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

            return(newEntity);
        }
コード例 #3
0
        /// <summary>
        /// Initializes any collection properties after deserialization, like next requests for paging.
        /// </summary>
        /// <param name="connectedOrganizationToInitialize">The <see cref="ConnectedOrganization"/> with the collection properties to initialize.</param>
        private void InitializeCollectionProperties(ConnectedOrganization connectedOrganizationToInitialize)
        {
            if (connectedOrganizationToInitialize != null && connectedOrganizationToInitialize.AdditionalData != null)
            {
                if (connectedOrganizationToInitialize.ExternalSponsors != null && connectedOrganizationToInitialize.ExternalSponsors.CurrentPage != null)
                {
                    connectedOrganizationToInitialize.ExternalSponsors.AdditionalData = connectedOrganizationToInitialize.AdditionalData;

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

                    if (!string.IsNullOrEmpty(nextPageLinkString))
                    {
                        connectedOrganizationToInitialize.ExternalSponsors.InitializeNextPageRequest(
                            this.Client,
                            nextPageLinkString);
                    }
                }

                if (connectedOrganizationToInitialize.InternalSponsors != null && connectedOrganizationToInitialize.InternalSponsors.CurrentPage != null)
                {
                    connectedOrganizationToInitialize.InternalSponsors.AdditionalData = connectedOrganizationToInitialize.AdditionalData;

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

                    if (!string.IsNullOrEmpty(nextPageLinkString))
                    {
                        connectedOrganizationToInitialize.InternalSponsors.InitializeNextPageRequest(
                            this.Client,
                            nextPageLinkString);
                    }
                }
            }
        }
コード例 #4
0
 /// <summary>
 /// Creates the specified ConnectedOrganization using POST.
 /// </summary>
 /// <param name="connectedOrganizationToCreate">The ConnectedOrganization to create.</param>
 /// <returns>The created ConnectedOrganization.</returns>
 public System.Threading.Tasks.Task <ConnectedOrganization> CreateAsync(ConnectedOrganization connectedOrganizationToCreate)
 {
     return(this.CreateAsync(connectedOrganizationToCreate, CancellationToken.None));
 }
 /// <summary>
 /// Adds the specified ConnectedOrganization to the collection via POST.
 /// </summary>
 /// <param name="connectedOrganization">The ConnectedOrganization to add.</param>
 /// <param name="cancellationToken">The <see cref="CancellationToken"/> for the request.</param>
 /// <returns>The created ConnectedOrganization.</returns>
 public System.Threading.Tasks.Task <ConnectedOrganization> AddAsync(ConnectedOrganization connectedOrganization, CancellationToken cancellationToken)
 {
     this.ContentType = "application/json";
     this.Method      = "POST";
     return(this.SendAsync <ConnectedOrganization>(connectedOrganization, cancellationToken));
 }
 /// <summary>
 /// Adds the specified ConnectedOrganization to the collection via POST.
 /// </summary>
 /// <param name="connectedOrganization">The ConnectedOrganization to add.</param>
 /// <returns>The created ConnectedOrganization.</returns>
 public System.Threading.Tasks.Task <ConnectedOrganization> AddAsync(ConnectedOrganization connectedOrganization)
 {
     return(this.AddAsync(connectedOrganization, CancellationToken.None));
 }