Ejemplo n.º 1
0
        public async Task Consume(ConsumeContext <OrderPlacedEvent> context)
        {
            Console.WriteLine($"order placed {context.Message.OrderId}");
            var order = await _ordersService.GetOrder(context.Message.OrderId);

            await _sendMailService.SendMail(order.Customer.Email, $"Zamówienie {order.Id} przyjęte", "OrderPlacedEmail", order);
        }
        public void SendMail_WithoutRequireFields_ReturnsFalse()
        {
            //act
            var actualResult = _sendMailService.SendMail(BlankEmail);

            //assert
            Assert.False(actualResult);
        }
Ejemplo n.º 3
0
        public ActionResult SendMail(Guid id, string subject, string body)
        {
            if (string.IsNullOrWhiteSpace(subject))
            {
                ModelState.AddModelError("subject", "Betreff muss vorhanden sein");
            }
            if (string.IsNullOrWhiteSpace(body))
            {
                ModelState.AddModelError("body", "Text muss vorhanden sein");
            }

            var speaker = _speakerService.GetSpeaker(id);

            if (string.IsNullOrWhiteSpace(speaker.Contact.EMail))
            {
                ModelState.AddModelError("", "Für den Sprecher ist keine Mail hinterlegt");
            }

            if (ModelState.IsValid)
            {
                try {
                    mailService.SendMail(speaker.Contact.EMail, subject, body);
                    return(RedirectToAction("Details", new { id }));
                } catch (Exception e) {
                    ModelState.AddModelError("", string.Format("{0}: {1} ", e.GetType().Name, e.Message));
                }
            }
            return(View(_speakerService.GetSpeaker(id).MapFrom <Speaker, SpeakerEditModel>()));
        }
Ejemplo n.º 4
0
        public void sendDocMail(SendMailModel model, int?headId = null, string contractorName = null)
        {
            var order = _dbcontext.Orders.Where(o => o.Id == model.OrderId).AsNoTracking().FirstOrDefault();

            if (order == null)
            {
                throw new NotFoundException();
            }

            var emails = new List <string>();

            headId         = headId ?? order.Head;
            contractorName = ((contractorName ?? order.Contractor) ?? "").ToUpper().Trim();
            if (headId.HasValue)
            {
                emails = _dbcontext.HeadStroyUsers.Where(o => o.id == headId.Value && o.Email != null && o.Email.Length > 0).Select(o => o.Email).AsNoTracking().ToList <string>();
            }

            var Enemails = _dbcontext.MainEnginiers.Where(o => o.Email != null && o.Email.Length > 0).Select(o => o.Email).AsNoTracking().ToList <string>();

            if (Enemails.Count > 0)
            {
                emails.AddRange(Enemails);
            }

            var contractor = _dbcontext.Kontragents.Where(o => o.name.ToUpper().Trim() == contractorName).AsNoTracking().FirstOrDefault();

            List <FileAttachment> files = null;

            if (model.Ids != null)
            {
                files = _dbcontext.OrderFiles.Where(f => model.Ids.Contains(f.Id)).Select(f => new FileAttachment()
                {
                    FilePath = Path.Combine(_filePath, order.Id.ToString(), f.RepFileName),
                    FileName = f.Filename
                }).ToList <FileAttachment>();
            }
            else
            {
                files = _dbcontext.OrderFiles.Where(f => f.OrderId == model.OrderId).Select(f => new FileAttachment()
                {
                    FilePath = Path.Combine(_filePath, order.Id.ToString(), f.RepFileName),
                    FileName = f.Filename
                }).ToList <FileAttachment>();
            }

            if (contractor != null && (contractor.email ?? "").Trim().Length > 0)
            {
                emails.Add(contractor.email);
            }

            if (files.Count > 0 && emails.Count > 0)
            {
                string mess = _sendMailService.SendMail("*****@*****.**", string.Join(", ", emails.ToArray()), "Предписания", "Отправитель: " + _authService.GetUserInfoModel().FullName, files);
                if (mess.Length != 0)
                {
                    throw new SendEmailException("Ошибка отправки.");
                }
            }
        }
        public async Task <string> SendEmail()
        {
            MailContent content = new MailContent
            {
                To      = "*****@*****.**",
                Subject = "Kiểm tra thử",
                Body    = "<p><strong>Xin chào xuanthulab.net</strong></p>"
            };

            await sendMailService.SendMail(content);

            return("ok");
        }
        private async Task <string> SendEmail()// (List<string> tos, string subject, string bodyContent)
        {
            MailContent content = new MailContent
            {
                To      = "*****@*****.**",
                Subject = "Kiểm tra thử",
                Body    = "<p><strong>Xin chào xuanthulab.net</strong></p>"
            };

            await sendMailService.SendMail(content);

            //await context.Response.WriteAsync("Send mail");
            return("ok");
        }
Ejemplo n.º 7
0
 private void TestenClick(object obj)
 {
     if (!IsValid())
     {
         return;
     }
     _mailService.Subject = SharedMethods.ReplaceToken(Subject, "123456", DateTime.Today,
                                                       "Mail Test Firma",
                                                       "Mail Test Kontaktname", "+43 (699) 123 123 456", "*****@*****.**"
                                                       );
     _mailService.MailBody = SharedMethods.ReplaceToken(Body, "123456", DateTime.Today,
                                                        "Mail Test Firma",
                                                        "Mail Test Kontaktname", "+43 (699) 123 123 456", "*****@*****.**"
                                                        );
     _mailService.SendMail();
 }
Ejemplo n.º 8
0
 public async Task <IActionResult> SendMail(MailContent mailContent)
 {
     return(Ok(await _sendMailService.SendMail(mailContent)));
 }