public void VerifyEmailNewBookInsertedParse()
        {
            var result = emailTemplate.GenerateHtmlFromTemplateAsync("NewBookInsertedTemplate", book).Result;

            //<!DOCTYPE html>\r\n<html lang=\"en\" xmlns=\"http://www.w3.org/1999/xhtml\">\r\n<head>\r\n    <meta charset=\"utf-8\" />\r\n    <title>Novo livro cadastrado - Sharebook</title>\r\n</head>\r\n<body>\r\n    <p>\r\n        Olá Cussa Mitre,\r\n    </p>\r\n    <p>\r\n        Um novo livro foi cadastrado. Veja mais informações abaixo:\r\n    </p>\r\n\r\n    <ul>\r\n        <li><strong>Livro: </strong>Lord of the Rings</li>\r\n        <li><strong>Autor: </strong>J. R. R. Tolkien</li>\r\n        <li><strong>Usuário: </strong>Rodrigo</li>\r\n    </ul>\r\n\r\n    <p>Sharebook</p>\r\n</body>\r\n</html>

            Assert.Contains("Olá Administrador(a),", result);
            Assert.Contains("<li><strong>Livro: </strong>Lord of the Rings</li>", result);
            Assert.Contains("<li><strong>Autor: </strong>J. R. R. Tolkien</li>", result);
            Assert.Contains("<li><strong>Usuário: </strong>Rodrigo</li>", result);
        }
Exemple #2
0
        public async Task SendEmailForgotMyPasswordToUserAsync(User user)
        {
            var vm = new
            {
                LinkForgotMyPassword = $"{_serverSettings.DefaultUrl}/ForgotPassword/{user.HashCodePassword}",
                User = user,
            };
            var html = await _emailTemplate.GenerateHtmlFromTemplateAsync("ForgotPasswordTemplate", vm);

            var title = "Esqueceu sua senha - Sharebook";
            await _emailService.Send(user.Email, user.Name, html, title);
        }
Exemple #3
0
        public void VerifyEmailContactUsNotificationParse()
        {
            var contactUs = new ContactUs()
            {
                Name  = "Rafael Rocha",
                Email = "*****@*****.**"
            };


            var result = emailTemplate.GenerateHtmlFromTemplateAsync("ContactUsNotificationTemplate", contactUs).Result;

            Assert.Contains("Olá, Rafael Rocha", result);
        }
        private async Task SendEmailBookRequestedToAdministrator(Book bookRequested, User requestingUser, User admin)
        {
            var vm = new
            {
                Book           = bookRequested,
                RequestingUser = requestingUser,
                Administrator  = admin
            };

            var html = await _emailTemplate.GenerateHtmlFromTemplateAsync(BookRequestedTemplate, vm);

            _emailService.Send(admin.Email, admin.Name, html, BookRequestedTitle);
        }
        private async Task SendEmailContactUsToAdministrator(ContactUs contactUs, User administrator)
        {
            var vm = new
            {
                ContactUs     = contactUs,
                Administrator = administrator
            };

            var html = await _emailTemplate.GenerateHtmlFromTemplateAsync(ContactUsTemplate, vm);

            bool copyAdmins = false;

            _emailService.Send(administrator.Email, administrator.Name, html, ContactUsTitle, copyAdmins);
        }
Exemple #6
0
        private void SendEmail(IList <Book> books)
        {
            var htmlTable = "<TABLE border=1 cellpadding=3 cellspacing=0><TR bgcolor='#ffff00'><TD><b>LIVRO</b></TD><TD><b>DIAS NA <BR>VITRINE</b></TD><TD><b>TOTAL <br>INTERESSADOS</b></TD><TD><b>DOADOR</b></TD><TD><b>FACILITADOR</b></TD><TD><b>ANOTAÇÕES</b></TD></TR>";

            foreach (var book in books)
            {
                var notes = book.FacilitatorNotes?.Replace("\n", "<BR>");

                htmlTable += string.Format("<TR><TD>{0}<BR>{1}</TD><TD>{2}</TD><TD>{3}</TD><TD>{4}<BR>{5}<BR>{6}<BR>{7}</TD><TD>{8}<BR>{9}<BR>{10}<BR>{11}</TD><TD>{12}</TD></TR>",
                                           book.Title,
                                           book.Status,
                                           book.DaysInShowcase(),
                                           book.TotalInterested(),
                                           book.User.Name, book.User.Email, book.User.Phone, book.User.Linkedin,
                                           book.UserFacilitator.Name, book.UserFacilitator.Email, book.UserFacilitator.Phone, book.UserFacilitator.Linkedin,
                                           notes);
            }

            htmlTable += "</TABLE>";

            var emailSubject = "SHAREBOOK - LISTA DE DOAÇÕES EM ATRASO.";

            var vm            = new { htmlTable };
            var emailBodyHTML = _emailTemplate.GenerateHtmlFromTemplateAsync("LateDonationNotification", vm).Result;

            _emailService.SendToAdmins(emailBodyHTML, emailSubject).Wait();
        }
Exemple #7
0
        private void SendEmailAdmin(IList <Book> booksLate, BookStatsDTO status)
        {
            var htmlTable = "<TABLE border=1 cellpadding=3 cellspacing=0><TR bgcolor='#ffff00'><TD><b>LIVRO</b></TD><TD><b>DIAS DE <BR>ATRASO</b></TD><TD><b>TOTAL <br>INTERESSADOS</b></TD><TD><b>DOADOR</b></TD><TD><b>FACILITADOR</b></TD><TD><b>ANOTAÇÕES</b></TD></TR>";

            foreach (var book in booksLate)
            {
                var notes = book.FacilitatorNotes?.Replace("\n", "<BR>");

                var whatsappLink = GetWhatsappLink(book.User.Phone);

                htmlTable += string.Format("<TR><TD>{0}<BR>{1}</TD><TD>{2}</TD><TD>{3}</TD><TD>{4}<BR>{5}<BR>{6}<BR>{7}</TD><TD>{8}<BR>{9}<BR>{10}<BR>{11}</TD><TD>{12}</TD></TR>",
                                           book.Title,
                                           book.Status,
                                           book.DaysLate(),
                                           book.TotalInterested(),
                                           book.User.Name, book.User.Email, whatsappLink, book.User.Linkedin,
                                           book.UserFacilitator.Name, book.UserFacilitator.Email, book.UserFacilitator.Phone, book.UserFacilitator.Linkedin,
                                           notes);
            }

            htmlTable += "</TABLE>";

            var emailSubject = "SHAREBOOK - STATUS DO DIA.";

            var vm = new {
                htmlTable,
                totalWaitingApproval = status.TotalWaitingApproval,
                totalLate            = booksLate.Count,
                totalOk = status.TotalOk
            };
            var emailBodyHTML = _emailTemplate.GenerateHtmlFromTemplateAsync("LateDonationNotification", vm).Result;

            _emailService.SendToAdmins(emailBodyHTML, emailSubject).Wait();
        }
Exemple #8
0
        public async Task SendEmailBookDonated(BookUser bookUser)
        {
            var bookDonated = bookUser.Book;

            if (bookDonated.User == null)
            {
                bookDonated.User = _userService.Find(bookUser.Book.UserId);
            }
            var vm = new
            {
                Book = bookDonated,
                bookUser.User
            };
            var html = await _emailTemplate.GenerateHtmlFromTemplateAsync(BookDonatedTemplate, vm);

            await _emailService.Send(bookUser.User.Email, bookUser.User.Name, html, BookDonatedTitle, true);
        }
Exemple #9
0
        public async Task SendEmailBookApproved(Book book)
        {
            if (book.User == null)
            {
                book.User = _userService.Get(book.UserId);
            }

            var vm = new
            {
                Book = book
            };

            bool copyAdmins = true;
            var  html       = await _emailTemplate.GenerateHtmlFromTemplateAsync(BookApprovedTemplate, vm);

            _emailService.Send(book.User.Email, book.User.Name, html, BookApprovedTitle, copyAdmins);
        }
Exemple #10
0
        public async Task SendEmailBookApproved(Book book)
        {
            if (book.User == null)
            {
                book.User = _userService.Find(book.UserId);
            }

            var vm = new
            {
                Book = book,
                book.User,
                ChooseDate = book.ChooseDate?.ToString("dd/MM/yyyy")
            };

            var html = await _emailTemplate.GenerateHtmlFromTemplateAsync(BookApprovedTemplate, vm);

            await _emailService.Send(book.User.Email, book.User.Name, html, BookApprovedTitle, true);
        }
Exemple #11
0
        public void SendEmailBookApproved(Book book)
        {
            if (book.User == null)
            {
                book.User = _userService.Find(book.UserId);
            }

            if (book.User.AllowSendingEmail)
            {
                var vm = new
                {
                    Book = book,
                    book.User,
                    ChooseDate = book.ChooseDate?.ToString("dd/MM/yyyy")
                };
                var html = _emailTemplate.GenerateHtmlFromTemplateAsync(BookApprovedTemplate, vm).Result;
                _emailService.Send(book.User.Email, book.User.Name, html, BookApprovedTitle, true);
            }
        }
Exemple #12
0
        public async void SendEmailForgotMyPasswordToUserAsync(User user)
        {
            var vm = new
            {
                LinkForgotMyPassword = $"{_serverSettings.DefaultUrl}/ForgotPassword/{user.HashCodePassword}",
                User = user,
            };
            var html = await _emailTemplate.GenerateHtmlFromTemplateAsync(ForgotPasswordTemplate, vm);

            await _emailService.Send(user.Email, user.Name, html, ForgotPasswordTitle);
        }
        private async Task SendEmailNewBookInsertedToAdministrator(Book book, User administrator)
        {
            var vm = new
            {
                Book          = book,
                Administrator = administrator
            };

            var html = await _emailTemplate.GenerateHtmlFromTemplateAsync(NewBookInsertedTemplate, vm);

            _emailService.Send(administrator.Email, administrator.Name, html, NewBookInsertedTitle);
        }
Exemple #14
0
        private void SendEmail(Book book)
        {
            var emailSubject = "Hoje é o dia de escolher o ganhador!";

            var vm = new
            {
                DonorName           = book.User.Name,
                BookTitle           = book.Title,
                FacilitatorName     = book.UserFacilitator.Name,
                FacilitatorEmail    = book.UserFacilitator.Email,
                FacilitatorWhatsapp = book.UserFacilitator.Phone,
                FacilitatorLinkedin = book.UserFacilitator.Linkedin
            };
            var emailBodyHTML = _emailTemplate.GenerateHtmlFromTemplateAsync("ChooseDateReminderTemplate", vm).Result;

            _emailService.Send(book.User.Email, book.User.Name, emailBodyHTML, emailSubject, copyAdmins: false);
        }
        private void SendEmail(Book book)
        {
            var emailSubject = "SHAREBOOK - RENOVAMOS SUA DOAÇÃO.";

            var vm = new
            {
                DonorName           = book.User.Name,
                BookTitle           = book.Title,
                BookSlug            = book.Slug,
                FacilitatorName     = book.UserFacilitator.Name,
                FacilitatorEmail    = book.UserFacilitator.Email,
                FacilitatorWhatsapp = book.UserFacilitator.Phone,
                FacilitatorLinkedin = book.UserFacilitator.Linkedin
            };
            var emailBodyHTML = _emailTemplate.GenerateHtmlFromTemplateAsync("ChooseDateRenewTemplate", vm).Result;

            _emailService.Send(book.User.Email, book.User.Name, emailBodyHTML, emailSubject, copyAdmins: false);
        }
        private void SendEmail(Book book)
        {
            var emailSubject = "SHAREBOOK - É HOJE!";

            var vm = new
            {
                DonorName           = book.User.Name,
                BookTitle           = book.Title,
                FacilitatorName     = book.UserFacilitator.Name,
                FacilitatorEmail    = book.UserFacilitator.Email,
                FacilitatorWhatsapp = book.UserFacilitator.Phone,
                FacilitatorLinkedin = book.UserFacilitator.Linkedin
            };
            var emailBodyHTML = _emailTemplate.GenerateHtmlFromTemplateAsync("ChooseDateReminderTemplate", vm).Result;

            // TODO: não enviar cópia para admins quando o job já estiver bem testado e amadurecido.
            var copyAdmins = true;

            _emailService.Send(book.User.Email, book.User.Name, emailBodyHTML, emailSubject, copyAdmins);
        }
        public void VerifyEmailParse()
        {
            var user = new User()
            {
                Id      = new Guid("5489A967-9320-4350-E6FC-08D5CC8498F3"),
                Name    = "Walter Vinicius",
                Email   = "*****@*****.**",
                Profile = Domain.Enums.Profile.User
            };
            var book = new Book()
            {
                Title      = "Lord of the Rings",
                Author     = "J. R. R. Tolkien",
                Image      = "lotr.png",
                ImageBytes = Encoding.UTF8.GetBytes("STRINGBASE64"),
                User       = user
            };
            var administrator = new User()
            {
                Id      = new Guid("5489A967-AAAA-BBBB-CCCC-08D5CC8498F3"),
                Name    = "Cussa Mitre",
                Email   = "*****@*****.**",
                Profile = Domain.Enums.Profile.Administrator
            };

            var vm = new
            {
                Book          = book,
                Administrator = administrator
            };

            var result = emailTemplate.GenerateHtmlFromTemplateAsync("NewBookInsertedTemplate", vm).Result;

            var expected = "<!DOCTYPE html>\r\n<html lang=\"en\" xmlns=\"http://www.w3.org/1999/xhtml\">\r\n<head>\r\n    <meta charset=\"utf-8\" />\r\n    <title>Novo livro cadastrado - Sharebook</title>\r\n</head>\r\n<body>\r\n    <p>\r\n        Olá Cussa Mitre,\r\n    </p>\r\n    <p>\r\n        Um novo livro foi cadastrado. Veja mais informações abaixo:\r\n    </p>\r\n\r\n    <ul>\r\n        <li><strong>Livro: </strong>Lord of the Rings</li>\r\n        <li><strong>Autor: </strong>J. R. R. Tolkien</li>\r\n        <li><strong>Usuário: </strong>Walter Vinicius</li>\r\n    </ul>\r\n\r\n    <p>Sharebook</p>\r\n</body>\r\n</html>  ";

            Assert.Equal(expected, result);
        }
Exemple #18
0
        private async Task SendEmailContactUsToAdministrator(ContactUs contactUs)
        {
            var html = await _emailTemplate.GenerateHtmlFromTemplateAsync(ContactUsTemplate, contactUs);

            await _emailService.SendToAdmins(html, ContactUsTitle);
        }