public virtual async Task <IActionResult> AskQuestion(ProductAskQuestionModel model, bool captchaValid) { var product = await _productService.GetProductById(model.ProductId); if (product == null || !product.Published || !_catalogSettings.AskQuestionEnabled) { return(NotFound()); } // validate CAPTCHA if (_captchaSettings.Enabled && _captchaSettings.ShowOnAskQuestionPage && !captchaValid) { ModelState.AddModelError("", _captchaSettings.GetWrongCaptchaMessage(_localizationService)); } if (ModelState.IsValid) { // email await _productViewModelService.SendProductAskQuestionMessage(product, model); //activity log await _customerActivityService.InsertActivity("PublicStore.AskQuestion", _workContext.CurrentCustomer.Id, _localizationService.GetResource("ActivityLog.PublicStore.AskQuestion")); model.SuccessfullySent = true; model.ProductSeName = product.GetSeName(_workContext.WorkingLanguage.Id); model.ProductName = product.GetLocalized(x => x.Name, _workContext.WorkingLanguage.Id); model.Result = _localizationService.GetResource("Products.AskQuestion.SuccessfullySent"); return(View(model)); } // If we got this far, something failed, redisplay form var customer = _workContext.CurrentCustomer; model.Id = product.Id; model.ProductName = product.GetLocalized(x => x.Name, _workContext.WorkingLanguage.Id); model.ProductSeName = product.GetSeName(_workContext.WorkingLanguage.Id); model.DisplayCaptcha = _captchaSettings.Enabled && _captchaSettings.ShowOnAskQuestionPage; return(View(model)); }