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

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

            this.InitializeCollectionProperties(newEntity);
            return(newEntity);
        }
        /// <summary>
        /// Updates the specified CalendarGroup using PATCH.
        /// </summary>
        /// <param name="calendarGroupToUpdate">The CalendarGroup to update.</param>
        /// <param name="cancellationToken">The <see cref="CancellationToken"/> for the request.</param>
        /// <returns>The updated CalendarGroup.</returns>
        public async Task <CalendarGroup> UpdateAsync(CalendarGroup calendarGroupToUpdate, CancellationToken cancellationToken)
        {
            this.ContentType = "application/json";
            this.Method      = "PATCH";
            var updatedEntity = await this.SendAsync <CalendarGroup>(calendarGroupToUpdate, cancellationToken).ConfigureAwait(false);

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

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

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