Beispiel #1
0
        public async Task <IActionResult> Contact(Contato contato)
        {
            if (!ModelState.IsValid)
            {
                ViewBag.Message = "<div class='alert alert-danger' role='alert'>Os campos Nome, E-mail e Contato são obrigatórios</div>";

                return(View(new Contato()));
            }

            if (!IsValidEmail(contato.Email))
            {
                ViewBag.Message = "<div class='alert alert-danger' role='alert'>Forneça um endereço válido para o e-mail</div>";

                return(View(new Contato()));
            }

            try
            {
                await email.SendAsync(contato);
            }
            catch
            {
                ViewBag.Message = "<div class='alert alert-danger' role='alert'>Ocorreu um erro desconhecido. Tente novamente</div>";

                return(View(new Contato()));
            }

            var option = new CookieOptions();

            option.Expires = DateTime.Now.AddSeconds(30);
            Response.Cookies.Append("EmailEnviado", "true", option);
            var boh = Request.Cookies["EmailEnviado"];

            return(RedirectToAction("Contact"));
        }
Beispiel #2
0
 private static Task <bool> SendAsync(
     IEmail email,
     EmailType type,
     IEnumerable <string> to,
     IEnumerable <string> cc,
     string subject,
     string content)
 => email.SendAsync(type, to, cc, subject, content);
Beispiel #3
0
        public async Task OnboardTenant()
        {
            NewTenantRequest tenantRequest = new()
            {
                Name          = OnboardingWorkflowItem.OrganizationName,
                Route         = OnboardingWorkflowItem.TenantRouteName,
                CreatorEmail  = _applicationUser.EmailAddress,
                ProductTierId = OnboardingWorkflowItem.ProductId,
                CategoryId    = OnboardingWorkflowItem.CategoryId
            };

            // Call new Admin API
            await _adminServiceClient.TenantsPOSTAsync(tenantRequest);

            OnboardingWorkflowItem.IsComplete = true;
            OnboardingWorkflowItem.Created    = DateTime.Now;

            await _email.SendAsync(_applicationUser.EmailAddress);
        }
Beispiel #4
0
        public async Task <IActionResult> OnPostAsync(string returnUrl = null)
        {
            // Generate a token that holds our input (ApplicationUser in this case).
            var token = JwtTokenGenerator(Input);

            // Generate the URL in the email link to the confirmation page.
            var uriBuilder = new UriBuilder("http://localhost:5000/Confirm");
            var query      = HttpUtility.ParseQueryString(uriBuilder.Query);

            query["token"]   = token;
            uriBuilder.Query = query.ToString();
            var urlString = uriBuilder.ToString();

            var emailBody = $"<p>Click on the link below to confirm your account.</p><p>{urlString}</p>";
            await _emailService.SendAsync(Input.Email, emailBody, "Confirm your account", _emailOptions.Value);

            Success = true;

            return(Page());
        }
Beispiel #5
0
 public async Task SendAsync(IEmail service)
 {
     var dto = CreateDto();
     await service.SendAsync(dto);
 }
    public async Task <IActionResult> ContactAsync(Contato contato)
    {
        await email.SendAsync(contato);

        return(Ok());
    }
 public Task ExecuteAsync(SendEmailCommand command)
 {
     return(_email.SendAsync(command.To, command.Body));
 }