Exemplo n.º 1
0
        private static void SendMail(Db db, User user, Client client, ILogger logger)
        {
            logger?.Info("Rendering template and sending email to user '" + user.Email + "' ...");

            var budgetCalculator = new BudgetCalculator(db, client);
            var sumCalculator    = new SumCalculator(db, client);
            var renderer         = new SummaryMailRenderer(db, budgetCalculator, sumCalculator);
            var mailer           = new SendGridMailer();
            var sender           = new SummaryMailSender(renderer, mailer);

            sender.RenderAndSend(user);
        }
Exemplo n.º 2
0
        public async Task <ActionResult> SummaryMailPreview()
        {
            var currentUser = await GetCurrentUser();

            var requestUrl = Request.Url;

            if (requestUrl == null)
            {
                throw new Exception("Request.Url is null. This should not be possible at this point.");
            }

            var budgetCalculator = new BudgetCalculator(Db, await GetCurrentClient());
            var sumCalculator    = new SumCalculator(Db, await GetCurrentClient());

            var summaryMailRenderer = new SummaryMailRenderer(Db, budgetCalculator, sumCalculator);
            var summaryMail         = await summaryMailRenderer.Render(currentUser);

            return(View(new SummaryMailPreviewViewModel
            {
                Html = summaryMail
            }));
        }