Exemplo n.º 1
0
        public void SendMessage(MailMessage mailMessage)
        {
            var sb        = new StringBuilder();
            var lineBreak = mailMessage.IsBodyHtml ? "<br />" : "\r\n";

            foreach (var mailAddress in mailMessage.To)
            {
                sb.Append(BuildLine(nameof(mailMessage.To), mailAddress, lineBreak));
            }
            foreach (var mailAddress in mailMessage.CC)
            {
                sb.Append(BuildLine(nameof(mailMessage.CC), mailAddress, lineBreak));
            }
            foreach (var mailAddress in mailMessage.Bcc)
            {
                sb.Append(BuildLine(nameof(mailMessage.Bcc), mailAddress, lineBreak));
            }

            sb.Append(mailMessage.Body);
            mailMessage.Body = sb.ToString();

            mailMessage.To.Clear();
            mailMessage.CC.Clear();
            mailMessage.Bcc.Clear();
            mailMessage.To.Add(_debugAddress);

            mailMessage.BodyEncoding = Encoding.UTF8;
            _mailSender.SendMessage(mailMessage);
        }
Exemplo n.º 2
0
        protected async override Task <WorkflowResult> PerformStep(string input, Subscriber subscriber, long chatId)
        {
            if (CurrentStep == (int)Steps.Start)
            {
                await Notifier.RequestEmail(chatId.ToString());

                CurrentStep = (int)Steps.EnterEmail;
                return(WorkflowResult.Continue);
            }

            if (CurrentStep == (int)Steps.EnterEmail)
            {
                if (string.IsNullOrWhiteSpace(input) || !input.EndsWith(Config.EmailDomain))
                {
                    await Notifier.IncorrectEmail(subscriber.TelegramId);

                    CurrentStep = (int)Steps.EnterEmail;

                    return(WorkflowResult.Continue);
                }

                subscriber.Email      = input;
                subscriber.IsVerified = false;
                subscriber.Pin        = _pinGenerator.GetRandomPin();

                await Notifier.EmailUpdated(subscriber);

                _mailSender.SendMessage("UN Big Brother bot verification code",
                                        $"Please send the following PIN to the bot through the chat: {subscriber.Pin}",
                                        subscriber.Email);

                CurrentStep = (int)Steps.VerifyEmail;
                return(WorkflowResult.Continue);
            }

            if (CurrentStep == (int)Steps.VerifyEmail)
            {
                var isNumeric = int.TryParse(input, out int code);
                if (isNumeric)
                {
                    if (await VerifyAccount(subscriber, code))
                    {
                        return(WorkflowResult.Finished);
                    }

                    return(WorkflowResult.Continue);
                }

                await Notifier.CouldNotVerifyAccount(subscriber);

                return(WorkflowResult.Continue);
            }

            return(WorkflowResult.Finished);
        }
Exemplo n.º 3
0
 public IActionResult Contact(ContactViewModel model)
 {
     if (ModelState.IsValid)
     {
         //Send Mail
         _mailSender.SendMessage("*****@*****.**", model.Subject, $"From: {model.Name} - {model.Email}, Message: {model.Message}");
         ViewBag.UserMessage = "Mail Sent";
         ModelState.Clear();
     }
     return(View());
 }
Exemplo n.º 4
0
        public async Task MakeOrder(
            UserDto userDto,
            List <OrderedProductDto> orderedProducts,
            decimal price,
            decimal advance)
        {
            var user = await _userDao.GetByEmail(userDto.Email);

            if (user == null)
            {
                user = userDto;
                user.CreationSource      = UserCreationSource.MadeOrder;
                user.SubscriptionOptions = SubscriptionOption.All;
                user.Id = await _userDao.AddUser(user);
            }
            ;

            var tasks  = orderedProducts.Select(op => _modelParser.ParseFromSku(op.Sku));
            var models = (await Task.WhenAll(tasks)).GroupBy(m => m.Sku).ToDictionary(m => m.Key, m => m.First());

            foreach (var prod in orderedProducts)
            {
                prod.SerializedProduct = JsonConvert.SerializeObject(models[prod.Sku], Formatting.Indented);
                prod.ProductLink       = $"https://ujin.org/ua/model/{models[prod.Sku].Identifier}?sku={prod.Sku}";
            }

            var order = new OrderDto
            {
                UserId          = user.Id,
                Price           = price,
                Advance         = advance,
                OrderedProducts = orderedProducts
            };

            await _orderDao.AddOrder(order);

            await _mailSender.SendMessage(new SimpleMail
            {
                From    = _mailSettings.SupportMail,
                To      = _mailSettings.MailTo,
                Subject = "Ujin jewelry: new order",
                Body    = GenerateMailMessage(order, user)
            });
        }
Exemplo n.º 5
0
        public void Send(Email email, UserId toUser)
        {
            var userDetails = repo.UserDetails(toUser);

            sender.SendMessage(userDetails.Email, email);
        }
Exemplo n.º 6
0
 public void SendMailShot(string to, string body)
 {
     _sender.SendMessage(new EmailMessage {
         To = to, Body = body
     });
 }