public virtual async Task <IActionResult> ProductEmailAFriendSend(ProductEmailAFriendModel model, bool captchaValid) { var product = await _productService.GetProductById(model.ProductId); if (product == null || !product.Published || !_catalogSettings.EmailAFriendEnabled) { return(RedirectToRoute("HomePage")); } //validate CAPTCHA if (_captchaSettings.Enabled && _captchaSettings.ShowOnEmailProductToFriendPage && !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("Products.EmailAFriend.OnlyRegisteredUsers")); } if (ModelState.IsValid) { //email await _productViewModelService.SendProductEmailAFriendMessage(product, model); model.ProductId = product.Id; model.ProductName = product.GetLocalized(x => x.Name, _workContext.WorkingLanguage.Id); model.ProductSeName = product.GetSeName(_workContext.WorkingLanguage.Id); model.SuccessfullySent = true; model.Result = _localizationService.GetResource("Products.EmailAFriend.SuccessfullySent"); return(View(model)); } //If we got this far, something failed, redisplay form model.ProductId = product.Id; model.ProductName = product.GetLocalized(x => x.Name, _workContext.WorkingLanguage.Id); model.ProductSeName = product.GetSeName(_workContext.WorkingLanguage.Id); model.DisplayCaptcha = _captchaSettings.Enabled && _captchaSettings.ShowOnEmailProductToFriendPage; return(View(model)); }