public ActionResult Newsletter(string[] selectedCategories) { if (selectedCategories == null || !selectedCategories.Any()) { return(RedirectToAction("Newsletter", routeValues: new { message = Messages.NewsletterSubscription })); } var categories = string.Join(",", selectedCategories); var newletterVm = new NewsletterViewModel { Active = true, Subscription = categories, UserId = User.Identity.GetUserId() }; var newsletter = _mapper.Map <NewsletterExtend>(newletterVm); var userId = User.Identity.GetUserId(); var newsletterValue = _newsletterService.GetSingle(i => i.UserId == userId); if (newsletterValue != null) { newsletterValue.Subscription = newletterVm.Subscription; newsletterValue.Active = newletterVm.Active; _newsletterService.Update(newsletterValue); } else { _newsletterService.Create(newsletter); } return(RedirectToAction(ProfileControllerAction.Index, routeValues: new { message = Messages.NewsletterSubscriptionConfirmation })); }
public async Task <IActionResult> SendEmailInitial(string email, string subject, string message) { var model = newsletterService.Create(email); var view = this.View(model); message = view.ToHtml(this.HttpContext); subject = "Confirm your registration for Tour Agency subscribtion"; await emailService.SendEmail(email, subject, message); return(RedirectToAction( nameof(HomeController.Index), "Home", new { area = string.Empty })); }