/// <summary>
        /// Initializes any collection properties after deserialization, like next requests for paging.
        /// </summary>
        /// <param name="notificationMessageTemplateToInitialize">The <see cref="NotificationMessageTemplate"/> with the collection properties to initialize.</param>
        private void InitializeCollectionProperties(NotificationMessageTemplate notificationMessageTemplateToInitialize)
        {
            if (notificationMessageTemplateToInitialize != null && notificationMessageTemplateToInitialize.AdditionalData != null)
            {
                if (notificationMessageTemplateToInitialize.LocalizedNotificationMessages != null && notificationMessageTemplateToInitialize.LocalizedNotificationMessages.CurrentPage != null)
                {
                    notificationMessageTemplateToInitialize.LocalizedNotificationMessages.AdditionalData = notificationMessageTemplateToInitialize.AdditionalData;

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

                    if (!string.IsNullOrEmpty(nextPageLinkString))
                    {
                        notificationMessageTemplateToInitialize.LocalizedNotificationMessages.InitializeNextPageRequest(
                            this.Client,
                            nextPageLinkString);
                    }
                }
            }
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Adds the specified NotificationMessageTemplate to the collection via POST.
 /// </summary>
 /// <param name="notificationMessageTemplate">The NotificationMessageTemplate to add.</param>
 /// <param name="cancellationToken">The <see cref="CancellationToken"/> for the request.</param>
 /// <returns>The created NotificationMessageTemplate.</returns>
 public System.Threading.Tasks.Task <NotificationMessageTemplate> AddAsync(NotificationMessageTemplate notificationMessageTemplate, CancellationToken cancellationToken)
 {
     this.ContentType = "application/json";
     this.Method      = "POST";
     return(this.SendAsync <NotificationMessageTemplate>(notificationMessageTemplate, cancellationToken));
 }
Ejemplo n.º 3
0
 /// <summary>
 /// Adds the specified NotificationMessageTemplate to the collection via POST.
 /// </summary>
 /// <param name="notificationMessageTemplate">The NotificationMessageTemplate to add.</param>
 /// <returns>The created NotificationMessageTemplate.</returns>
 public System.Threading.Tasks.Task <NotificationMessageTemplate> AddAsync(NotificationMessageTemplate notificationMessageTemplate)
 {
     return(this.AddAsync(notificationMessageTemplate, CancellationToken.None));
 }
        /// <summary>
        /// Creates the specified NotificationMessageTemplate using POST.
        /// </summary>
        /// <param name="notificationMessageTemplateToCreate">The NotificationMessageTemplate to create.</param>
        /// <param name="cancellationToken">The <see cref="CancellationToken"/> for the request.</param>
        /// <returns>The created NotificationMessageTemplate.</returns>
        public async System.Threading.Tasks.Task <NotificationMessageTemplate> CreateAsync(NotificationMessageTemplate notificationMessageTemplateToCreate, CancellationToken cancellationToken)
        {
            this.ContentType = "application/json";
            this.Method      = "POST";
            var newEntity = await this.SendAsync <NotificationMessageTemplate>(notificationMessageTemplateToCreate, cancellationToken).ConfigureAwait(false);

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

            this.InitializeCollectionProperties(updatedEntity);
            return(updatedEntity);
        }