public virtual ActionResult ArticleEmailAFriend(int articleId) { var article = _articleService.GetArticleById(articleId); if (article == null || article.Deleted || !article.Published || !_catalogSettings.EmailAFriendEnabled) { return(RedirectToRoute("HomePage")); } var model = new ArticleEmailAFriendModel(); model = _articleModelFactory.PrepareArticleEmailAFriendModel(model, article, false); return(View(model)); }
public virtual ActionResult ArticleEmailAFriendSend(ArticleEmailAFriendModel model, bool captchaValid) { var article = _articleService.GetArticleById(model.ArticleId); if (article == null || article.Deleted || !article.Published || !_catalogSettings.EmailAFriendEnabled) { return(RedirectToRoute("HomePage")); } //validate CAPTCHA if (_captchaSettings.Enabled && _captchaSettings.ShowOnEmailArticleToFriendPage && !captchaValid) { ModelState.AddModelError("", _captchaSettings.GetWrongCaptchaMessage(_localizationService)); } //check whether the current customer is guest and ia allowed to email a friend if (_workContext.CurrentCustomer.IsGuest() && !_catalogSettings.AllowAnonymousUsersToEmailAFriend) { ModelState.AddModelError("", _localizationService.GetResource("Articles.EmailAFriend.OnlyRegisteredUsers")); } if (ModelState.IsValid) { //email _workflowMessageService.SendArticleEmailAFriendMessage(_workContext.CurrentCustomer, _workContext.WorkingLanguage.Id, article, model.YourEmailAddress, model.FriendEmail, Core.Html.HtmlHelper.FormatText(model.PersonalMessage, false, true, false, false, false, false)); model = _articleModelFactory.PrepareArticleEmailAFriendModel(model, article, true); model.SuccessfullySent = true; model.Result = _localizationService.GetResource("Articles.EmailAFriend.SuccessfullySent"); return(View(model)); } //If we got this far, something failed, redisplay form model = _articleModelFactory.PrepareArticleEmailAFriendModel(model, article, true); return(View(model)); }