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

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

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

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

                    if (!string.IsNullOrEmpty(nextPageLinkString))
                    {
                        riskyUserToInitialize.History.InitializeNextPageRequest(
                            this.Client,
                            nextPageLinkString);
                    }
                }
            }
        }
 /// <summary>
 /// Adds the specified RiskyUser to the collection via POST.
 /// </summary>
 /// <param name="riskyUser">The RiskyUser to add.</param>
 /// <param name="cancellationToken">The <see cref="CancellationToken"/> for the request.</param>
 /// <returns>The created RiskyUser.</returns>
 public System.Threading.Tasks.Task <RiskyUser> AddAsync(RiskyUser riskyUser, CancellationToken cancellationToken)
 {
     this.ContentType = "application/json";
     this.Method      = "POST";
     return(this.SendAsync <RiskyUser>(riskyUser, cancellationToken));
 }
 /// <summary>
 /// Adds the specified RiskyUser to the collection via POST.
 /// </summary>
 /// <param name="riskyUser">The RiskyUser to add.</param>
 /// <returns>The created RiskyUser.</returns>
 public System.Threading.Tasks.Task <RiskyUser> AddAsync(RiskyUser riskyUser)
 {
     return(this.AddAsync(riskyUser, CancellationToken.None));
 }
Beispiel #6
0
 /// <summary>
 /// Creates the specified RiskyUser using POST.
 /// </summary>
 /// <param name="riskyUserToCreate">The RiskyUser to create.</param>
 /// <returns>The created RiskyUser.</returns>
 public System.Threading.Tasks.Task <RiskyUser> CreateAsync(RiskyUser riskyUserToCreate)
 {
     return(this.CreateAsync(riskyUserToCreate, CancellationToken.None));
 }