示例#1
0
        /// <summary>
        /// Initializes any collection properties after deserialization, like next requests for paging.
        /// </summary>
        /// <param name="userInstallStateSummaryToInitialize">The <see cref="UserInstallStateSummary"/> with the collection properties to initialize.</param>
        private void InitializeCollectionProperties(UserInstallStateSummary userInstallStateSummaryToInitialize)
        {
            if (userInstallStateSummaryToInitialize != null && userInstallStateSummaryToInitialize.AdditionalData != null)
            {
                if (userInstallStateSummaryToInitialize.DeviceStates != null && userInstallStateSummaryToInitialize.DeviceStates.CurrentPage != null)
                {
                    userInstallStateSummaryToInitialize.DeviceStates.AdditionalData = userInstallStateSummaryToInitialize.AdditionalData;

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

                    if (!string.IsNullOrEmpty(nextPageLinkString))
                    {
                        userInstallStateSummaryToInitialize.DeviceStates.InitializeNextPageRequest(
                            this.Client,
                            nextPageLinkString);
                    }
                }
            }
        }
示例#2
0
        /// <summary>
        /// Creates the specified UserInstallStateSummary using POST.
        /// </summary>
        /// <param name="userInstallStateSummaryToCreate">The UserInstallStateSummary to create.</param>
        /// <param name="cancellationToken">The <see cref="CancellationToken"/> for the request.</param>
        /// <returns>The created UserInstallStateSummary.</returns>
        public async System.Threading.Tasks.Task <UserInstallStateSummary> CreateAsync(UserInstallStateSummary userInstallStateSummaryToCreate, CancellationToken cancellationToken)
        {
            this.ContentType = "application/json";
            this.Method      = "POST";
            var newEntity = await this.SendAsync <UserInstallStateSummary>(userInstallStateSummaryToCreate, cancellationToken).ConfigureAwait(false);

            this.InitializeCollectionProperties(newEntity);
            return(newEntity);
        }
示例#3
0
 /// <summary>
 /// Creates the specified UserInstallStateSummary using POST.
 /// </summary>
 /// <param name="userInstallStateSummaryToCreate">The UserInstallStateSummary to create.</param>
 /// <returns>The created UserInstallStateSummary.</returns>
 public System.Threading.Tasks.Task <UserInstallStateSummary> CreateAsync(UserInstallStateSummary userInstallStateSummaryToCreate)
 {
     return(this.CreateAsync(userInstallStateSummaryToCreate, CancellationToken.None));
 }
示例#4
0
        /// <summary>
        /// Updates the specified UserInstallStateSummary using PATCH.
        /// </summary>
        /// <param name="userInstallStateSummaryToUpdate">The UserInstallStateSummary 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 UserInstallStateSummary.</returns>
        public async System.Threading.Tasks.Task <UserInstallStateSummary> UpdateAsync(UserInstallStateSummary userInstallStateSummaryToUpdate, CancellationToken cancellationToken)
        {
            if (userInstallStateSummaryToUpdate.AdditionalData != null)
            {
                if (userInstallStateSummaryToUpdate.AdditionalData.ContainsKey(Constants.HttpPropertyNames.ResponseHeaders) ||
                    userInstallStateSummaryToUpdate.AdditionalData.ContainsKey(Constants.HttpPropertyNames.StatusCode))
                {
                    throw new ClientException(
                              new Error
                    {
                        Code    = GeneratedErrorConstants.Codes.NotAllowed,
                        Message = String.Format(GeneratedErrorConstants.Messages.ResponseObjectUsedForUpdate, userInstallStateSummaryToUpdate.GetType().Name)
                    });
                }
            }
            if (userInstallStateSummaryToUpdate.AdditionalData != null)
            {
                if (userInstallStateSummaryToUpdate.AdditionalData.ContainsKey(Constants.HttpPropertyNames.ResponseHeaders) ||
                    userInstallStateSummaryToUpdate.AdditionalData.ContainsKey(Constants.HttpPropertyNames.StatusCode))
                {
                    throw new ClientException(
                              new Error
                    {
                        Code    = GeneratedErrorConstants.Codes.NotAllowed,
                        Message = String.Format(GeneratedErrorConstants.Messages.ResponseObjectUsedForUpdate, userInstallStateSummaryToUpdate.GetType().Name)
                    });
                }
            }
            this.ContentType = "application/json";
            this.Method      = "PATCH";
            var updatedEntity = await this.SendAsync <UserInstallStateSummary>(userInstallStateSummaryToUpdate, cancellationToken).ConfigureAwait(false);

            this.InitializeCollectionProperties(updatedEntity);
            return(updatedEntity);
        }
示例#5
0
 /// <summary>
 /// Adds the specified UserInstallStateSummary to the collection via POST.
 /// </summary>
 /// <param name="userInstallStateSummary">The UserInstallStateSummary to add.</param>
 /// <param name="cancellationToken">The <see cref="CancellationToken"/> for the request.</param>
 /// <returns>The created UserInstallStateSummary.</returns>
 public System.Threading.Tasks.Task <UserInstallStateSummary> AddAsync(UserInstallStateSummary userInstallStateSummary, CancellationToken cancellationToken)
 {
     this.ContentType = "application/json";
     this.Method      = "POST";
     return(this.SendAsync <UserInstallStateSummary>(userInstallStateSummary, cancellationToken));
 }
示例#6
0
 /// <summary>
 /// Adds the specified UserInstallStateSummary to the collection via POST.
 /// </summary>
 /// <param name="userInstallStateSummary">The UserInstallStateSummary to add.</param>
 /// <returns>The created UserInstallStateSummary.</returns>
 public System.Threading.Tasks.Task <UserInstallStateSummary> AddAsync(UserInstallStateSummary userInstallStateSummary)
 {
     return(this.AddAsync(userInstallStateSummary, CancellationToken.None));
 }