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

            this.InitializeCollectionProperties(updatedEntity);
            return(updatedEntity);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Creates the specified TimeOff using POST.
        /// </summary>
        /// <param name="timeOffToCreate">The TimeOff to create.</param>
        /// <param name="cancellationToken">The <see cref="CancellationToken"/> for the request.</param>
        /// <returns>The created TimeOff.</returns>
        public async System.Threading.Tasks.Task <TimeOff> CreateAsync(TimeOff timeOffToCreate, CancellationToken cancellationToken = default)
        {
            this.ContentType = CoreConstants.MimeTypeNames.Application.Json;
            this.Method      = HttpMethods.POST;
            var newEntity = await this.SendAsync <TimeOff>(timeOffToCreate, cancellationToken).ConfigureAwait(false);

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

            this.InitializeCollectionProperties(newEntity);
            return(newEntity);
        }
Ejemplo n.º 4
0
 /// <summary>
 /// Creates the specified TimeOff using POST and returns a <see cref="GraphResponse{TimeOff}"/> object.
 /// </summary>
 /// <param name="timeOffToCreate">The TimeOff to create.</param>
 /// <param name="cancellationToken">The <see cref="CancellationToken"/> for the request.</param>
 /// <returns>The <see cref="GraphResponse{TimeOff}"/> object of the request.</returns>
 public System.Threading.Tasks.Task <GraphResponse <TimeOff> > CreateResponseAsync(TimeOff timeOffToCreate, CancellationToken cancellationToken = default)
 {
     this.ContentType = CoreConstants.MimeTypeNames.Application.Json;
     this.Method      = HttpMethods.POST;
     return(this.SendAsyncWithGraphResponse <TimeOff>(timeOffToCreate, cancellationToken));
 }
Ejemplo n.º 5
0
 /// <summary>
 /// Initializes any collection properties after deserialization, like next requests for paging.
 /// </summary>
 /// <param name="timeOffToInitialize">The <see cref="TimeOff"/> with the collection properties to initialize.</param>
 private void InitializeCollectionProperties(TimeOff timeOffToInitialize)
 {
 }
 /// <summary>
 /// Creates the specified TimeOff using POST.
 /// </summary>
 /// <param name="timeOffToCreate">The TimeOff to create.</param>
 /// <returns>The created TimeOff.</returns>
 public System.Threading.Tasks.Task <TimeOff> CreateAsync(TimeOff timeOffToCreate)
 {
     return(this.CreateAsync(timeOffToCreate, CancellationToken.None));
 }
 /// <summary>
 /// Adds the specified TimeOff to the collection via POST.
 /// </summary>
 /// <param name="timeOff">The TimeOff to add.</param>
 /// <param name="cancellationToken">The <see cref="CancellationToken"/> for the request.</param>
 /// <returns>The created TimeOff.</returns>
 public System.Threading.Tasks.Task <TimeOff> AddAsync(TimeOff timeOff, CancellationToken cancellationToken)
 {
     this.ContentType = "application/json";
     this.Method      = "POST";
     return(this.SendAsync <TimeOff>(timeOff, cancellationToken));
 }
 /// <summary>
 /// Adds the specified TimeOff to the collection via POST.
 /// </summary>
 /// <param name="timeOff">The TimeOff to add.</param>
 /// <returns>The created TimeOff.</returns>
 public System.Threading.Tasks.Task <TimeOff> AddAsync(TimeOff timeOff)
 {
     return(this.AddAsync(timeOff, CancellationToken.None));
 }
Ejemplo n.º 9
0
 /// <summary>
 /// Adds the specified TimeOff to the collection via POST.
 /// </summary>
 /// <param name="timeOff">The TimeOff to add.</param>
 /// <param name="cancellationToken">The <see cref="CancellationToken"/> for the request.</param>
 /// <returns>The created TimeOff.</returns>
 public System.Threading.Tasks.Task <TimeOff> AddAsync(TimeOff timeOff, CancellationToken cancellationToken = default)
 {
     this.ContentType = CoreConstants.MimeTypeNames.Application.Json;
     this.Method      = HttpMethods.POST;
     return(this.SendAsync <TimeOff>(timeOff, cancellationToken));
 }