public ActionResult EmailPromoCode(int id)
        {
            var promoCode = _promoCodesRepository.Find(id);
            var model     = new EmailPromoCodeViewModel
            {
                PromoCode = promoCode
            };

            return(View(model));
        }
        public ActionResult EmailPromoCode(EmailPromoCodeViewModel model)
        {
            try
            {
                _userService.SendPromoCode(model);
            }
            catch (Exception e)
            {
                _logger.Error($"AccountController => EmailPromocode => Error: {e.GetFullErrorMessage()}");
                throw;
            }

            return(RedirectToAction("PromoCodeEmailSent"));
        }
Beispiel #3
0
        public void SendPromoCode(EmailPromoCodeViewModel model)
        {
            var template = Dictionary.PromoCodeEmail;
            var title    = Dictionary.PromoCodeEmailTitle;
            var contact  = _contactService.GetOrCreateContact("", model.Name, model.EmailAddress);

            _mailer.SendEmail(title, TemplateProcessor.PopulateTemplate(template, new
            {
                Title = title,
                model.FirstName,
                model.EmailAddress,
                ImageUrl          = _urlHelper.AbsoluteContent(_config.CompanyLogoUrl),
                PrivacyPolicyLink = _urlHelper.AbsoluteAction("PrivacyPolicy", "Home"),
                UnsubscribeLink   = _urlHelper.AbsoluteAction("Unsubscribe", "Account", new { code = contact.Name }),
                PromoLink         = _urlHelper.AbsoluteAction("Register", "Account", new { promoCode = model.PromoCode.Code }),
                PromoDetails      = model.PromoCode.Details,
                DateTime.Now.Year
            }), model.EmailAddress, model.Name, _config.SupportEmailAddress, _config.CompanyName);

            model.PromoCode.SentOn = DateTime.Now;
            _promoCodesRepository.Update(model.PromoCode);
        }