Пример #1
0
        private async Task SendConfirmationEmail(Translate translate, string email, ApplicationUser user)
        {
            string code = await userManager.GenerateEmailConfirmationTokenAsync(user);

            var callbackUrl = Url.Action("ConfirmEmail", "Account", RouteUserIdCodeCulture(user.Id, code), protocol: HttpContext.Request.Scheme);

            await emailMessageProvider.SendEmailAsync(
                new MailAddress[] { new MailAddress(email) },
                translate.Get("AUTH.CONFIRMING_EMAIL_EMAIL_HEAD"),
                string.Format(translate.Get("AUTH.CONFIRMING_EMAIL_EMAIL_BODY"), callbackUrl));
        }
Пример #2
0
        //// PUT api/values/5
        //[HttpPut("{id}")]
        //public ActionResult Put(int id, [FromBody]string value)
        //{
        //}

        //// DELETE api/values/5
        //[HttpDelete("{id}")]
        //public ActionResult Delete(int id)
        //{
        //}

        //private async Task SendConfirmationEmail(UserModel model, ApplicationUser user)
        //{
        //    string code = await userManager.GenerateEmailConfirmationTokenAsync(user);
        //    var callbackUrl = Url.Action("ConfirmEmail", "Account", new { userId = user.Id, code = code }, protocol: HttpContext.Request.Scheme);

        //    await MessageServices.SendEmailAsync(model.Email, "Confirm your account", "Please confirm your email by clicking this link: <a href=\"" + callbackUrl + "\">link</a>", cancellationToken: HttpContext.RequestAborted);
        //}

        private async Task SetPasswordEmail(string email, ApplicationUser user)
        {
            var translate = new Translate();

            string code = await userManager.GeneratePasswordResetTokenAsync(user);

            var callbackUrl = Url.Action("FirstLogin", "Account", new { code = code }, protocol: HttpContext.Request.Scheme);
            await emailMessageProvider.SendEmailAsync(
                new MailAddress[] { new MailAddress(email) },
                translate.Get("AUTH.FIRST_LOGIN_EMAIL_HEAD"),
                string.Format(translate.Get("AUTH.FIRST_LOGIN_EMAIL_BODY"), callbackUrl));
        }
Пример #3
0
        private async Task SendEmailReport(MemoryStream reportPdfStream, Translate translate, Report report)
        {
            var subject   = Encoding.UTF8.GetBytes($"{report.EmailSubject} #{report.Number}");
            var emailHtml = Encoding.UTF8.GetBytes(report.EmailBody.ToEmailHtml());

            await emailMessageProvider.SendEmailAsync(
                report.ToEmail.ToMailAddressArray(),
                Encoding.UTF8.GetString(subject),
                Encoding.UTF8.GetString(emailHtml),
                fromEmailAsCc : new MailAddress(report.FromEmail),
                attachmentName : string.Format("{0} {1}.pdf", translate.Get("REPORT.FILENAME"), report.Number),
                attachmentStream : reportPdfStream);

            reportPdfStream.Position = 0;
        }
Пример #4
0
        private async Task SendEmailInvoice(MemoryStream invoicePdfStream, Translate translate, Invoice invoice)
        {
            var subject   = Encoding.UTF8.GetBytes($"{invoice.EmailSubject} #{invoice.Number}");
            var emailHtml = Encoding.UTF8.GetBytes(invoice.EmailBody.ToEmailHtml());

            await emailMessageProvider.SendEmailAsync(
                invoice.ToEmail.ToMailAddressArray(),
                Encoding.UTF8.GetString(subject),
                Encoding.UTF8.GetString(emailHtml),
                fromEmailAsCc : new MailAddress(invoice.FromEmail),
                attachmentName : string.Format("{0} {1}.pdf", !invoice.CreditNote ? translate.Get("INVOICE.FILENAME") : translate.Get("INVOICE.CREDIT_NOTE_FILENAME"), invoice.Number),
                attachmentStream : invoicePdfStream);

            invoicePdfStream.Position = 0;
        }
Пример #5
0
        public async Task <IActionResult> Support(SupportViewModel model)
        {
            var translate = new Translate();

            ViewBag.Translate = translate;

            if (ModelState.IsValid)
            {
                await emailMessageProvider.SendEmailAsync(
                    new MailAddress[] { new MailAddress("*****@*****.**") },
                    $"{translate.Get("SUPPORT.SUPPORT")} [id:{DateTime.Now.Ticks}]", model.Message.ToHtml(),
                    fromEmailAsCc : new MailAddress(model.Email));

                return(RedirectToAction("SupportConfirmation", Request.RouteCulture()));
            }

            return(View(model));
        }
Пример #6
0
        public async Task <IActionResult> Post([FromBody] SupportApi item)
        {
            if (!ModelState.IsValidUpdated())
            {
                return(new BadRequestObjectResult(ModelState));
            }

            var translate = new Translate();

            var user = await DbContext.Users.Where(u => u.Id == CurrentUserId).Select(u => new { u.FullName, u.Email }).FirstAsync();

            await emailMessageProvider.SendEmailAsync(
                new MailAddress[] { new MailAddress("*****@*****.**") },
                $"{translate.Get("SUPPORT.SUPPORT")} [id:{DateTime.Now.Ticks}]", item.Message.ToHtml(),
                fromEmailAsCc : new MailAddress(user.Email));

            return(Ok());
        }