/// <summary>
        /// Отправка посетителю сообщения со ссылкой, необходимой
        /// для завершения регистрации аккаунта
        /// </summary>
        /// <param name="name">Имя посетителя</param>
        /// <param name="email">Email адрес посетителя</param>
        /// <param name="url">Ссылка для завершения регистрации аккаунта</param>
        /// <returns> Void </returns>
        public async Task SendConfirmationAsync(string name, string email, string url)
        {
            if (string.IsNullOrEmpty(name))
            {
                throw new ArgumentException(nameof(name));
            }

            if (string.IsNullOrEmpty(email))
            {
                throw new ArgumentException(nameof(email));
            }

            if (string.IsNullOrEmpty(url))
            {
                throw new ArgumentException(nameof(url));
            }

            try
            {
                var confirmation = new ConfirmationNotification()
                {
                    Receiver = new Receiver()
                    {
                        Emails = new List <string>()
                        {
                            email
                        },
                        FirstName = name
                    },
                    Url = url
                };
                string template = _unitOfWork.EmailTemplateRepository.GetById(
                    Convert.ToInt32(Resources.Confirmation)).Body;
                string body = Engine.Razor.RunCompile(
                    template,
                    Resources.Confirmation,
                    null,
                    new { Confirmation = confirmation });
                var messageToSend = CreateMessage(confirmation.Receiver, body);
                await SendEmailAsync(_transport.ElementAt(0), new[] { messageToSend });
            }
            catch (EntityException exception)
            {
                _logger.Error(exception.Message);
            }
            catch (DbException exception)
            {
                _logger.Error(exception.Message);
            }
            catch (Exception exception)
            {
                _logger.Error(exception.Message);
            }
        }
Example #2
0
 public void Notify(SignedLedger ledger)
 {
     foreach (var subscriptor in subscriptors)
     {
         var notification = new ConfirmationNotification()
         {
             Hash         = ledger.Hash.ToBase64(),
             Height       = ledger.GetHeight(),
             Timestamp    = ledger.GetTimestamp(),
             Transactions = GetTransactions(subscriptor.Value, ledger)
         };
         Send(subscriptor.Key, new NotificationMessage(notification));
     }
 }