public async Task <Stream> RenderAsync(CertificateVM vm)
        {
            var html = await _renderService.RenderViewToStringAsync(Template, vm);

            return(await _pdfRenderService.RenderHtmlAsync(html, new PdfRenderOptions
            {
                Format = "A4",
                Scale = 0.8f
            }));
        }
Exemplo n.º 2
0
        public async Task <IActionResult> OnPostAsync(string returnUrl = null)
        {
            ReturnUrl = returnUrl;
            if (ModelState.IsValid)
            {
                var user = new ApplicationUser {
                    Name = Input.Name, UserName = Input.Email, Email = Input.Email, PhoneNumber = Input.Phone
                };
                var result = await _userManager.CreateAsync(user, Input.Password);

                if (result.Succeeded)
                {
                    _logger.LogInformation("User created a new account with password.");

                    var code = await _userManager.GenerateEmailConfirmationTokenAsync(user);

                    var callbackUrl = Url.EmailConfirmationLink(user.Id, code, Request.Scheme);

                    var emailVM = new EmailMessage()
                    {
                        Name    = Input.Name,
                        Email   = Input.Email,
                        Subject = "En liten bekreftelse bare...",
                        Message = $@"<p>Vi har snart laget en ny bruker til deg, men vil bare at du bekrefter med å trykke på lenken!</p>
								<p><a href='{callbackUrl}'>Bekreft her</a></p>
								<p></p>
								<p>Hvis lenken ikke virker, så kan du kopiere inn teksten under i nettleseren:
								{callbackUrl} </p>"
                    };
                    var emailString = await _renderService.RenderViewToStringAsync("Templates/Email/StandardEmail", emailVM);

                    await _emailSender.SendEmailAsync(emailVM.Email, emailVM.Subject, emailString);

                    return(RedirectToPage("/Info/EmailSent"));
                }
                foreach (var error in result.Errors)
                {
                    ModelState.AddModelError(string.Empty, error.Description);
                }
            }

            // If we got this far, something failed, redisplay form
            return(Page());
        }
Exemplo n.º 3
0
        protected async Task SendAsync(string emailAddress, string subject, object vm, Attachment attachment)
        {
            var email = await _renderService.RenderViewToStringAsync(Template, vm);

            await _emailSender.SendEmailAsync(emailAddress, subject, email, attachment);
        }