示例#1
0
        /// <summary>
        /// Publish sms notification
        /// </summary>
        /// <param name="notificationName">Name of the notification. Default email template of the specified notification will be used</param>
        /// <param name="data">Data that is used to fill template</param>
        /// <param name="mobileNo">Recipient mobile number</param>
        /// <param name="sourceEntity">Optional parameter. If notification is an Entity level notification, specifies the entity the notification relates to.</param>
        /// <returns></returns>
        public async Task PublishSmsNotificationAsync <TData>(string notificationName,
                                                              TData data,
                                                              string mobileNo,
                                                              object sourceEntity = null) where TData : NotificationData
        {
            if (string.IsNullOrWhiteSpace(mobileNo))
            {
                throw new Exception($"{nameof(mobileNo)} must not be null");
            }

            var entityIdentifier = GetEntityIdentifier(sourceEntity);

            var wrappedData = new ShaNotificationData(data)
            {
                SendType      = RefListNotificationType.SMS,
                RecipientText = mobileNo
            };
            await _notificationPublisher.PublishAsync(notificationName, wrappedData, entityIdentifier);
        }
示例#2
0
        /// <summary>
        /// Publish email notification
        /// </summary>
        /// <param name="notificationName">Name of the notification. Default email template of the specified notification will be used</param>
        /// <param name="data">Data that is used to fill template</param>
        /// <param name="emailAddress">Recipient email address</param>
        /// <param name="sourceEntity">Optional parameter. If notification is an Entity level notification, specifies the entity the notification relates to.</param>
        /// <returns></returns>
        public async Task PublishEmailNotificationAsync <TData>(string notificationName,
                                                                TData data,
                                                                string emailAddress,
                                                                List <NotificationAttachmentDto> attachments = null,
                                                                object sourceEntity = null) where TData : NotificationData
        {
            if (string.IsNullOrWhiteSpace(emailAddress))
            {
                throw new Exception($"{nameof(emailAddress)} must not be null");
            }

            var entityIdentifier = GetEntityIdentifier(sourceEntity);

            var wrappedData = new ShaNotificationData(data)
            {
                SendType      = RefListNotificationType.Email,
                RecipientText = emailAddress,
                Attachments   = attachments
            };
            await _notificationPublisher.PublishAsync(notificationName, wrappedData, entityIdentifier);
        }