public ActionResult AskQuestion(int id) { var product = _productService.GetProductById(id); if (product == null || product.Deleted || !product.Published || !_catalogSettings.AskQuestionEnabled) return HttpNotFound(); var customer = _services.WorkContext.CurrentCustomer; var model = new ProductAskQuestionModel(); model.Id = product.Id; model.ProductName = product.GetLocalized(x => x.Name); model.ProductSeName = product.GetSeName(); model.SenderEmail = customer.Email; model.SenderName = customer.GetFullName(); model.SenderPhone = customer.GetAttribute<string>(SystemCustomerAttributeNames.Phone); model.Question = T("Products.AskQuestion.Question.Text").Text.FormatCurrentUI(model.ProductName); model.DisplayCaptcha = _captchaSettings.Enabled && _captchaSettings.ShowOnAskQuestionPage; return View(model); }
public ActionResult AskQuestionSend(ProductAskQuestionModel model, bool captchaValid) { var product = _productService.GetProductById(model.Id); if (product == null || product.Deleted || !product.Published || !_catalogSettings.AskQuestionEnabled) return HttpNotFound(); // validate CAPTCHA if (_captchaSettings.Enabled && _captchaSettings.ShowOnAskQuestionPage && !captchaValid) { ModelState.AddModelError("", T("Common.WrongCaptcha")); } if (ModelState.IsValid) { // email var result = _workflowMessageService.SendProductQuestionMessage( _services.WorkContext.CurrentCustomer, _services.WorkContext.WorkingLanguage.Id, product, model.SenderEmail, model.SenderName, model.SenderPhone, Core.Html.HtmlUtils.FormatText(model.Question, false, true, false, false, false, false)); if (result > 0) { this.NotifySuccess(T("Products.AskQuestion.Sent"), true); return RedirectToRoute("Product", new { SeName = product.GetSeName() }); } else { ModelState.AddModelError("", "Fehler beim Versenden der Email. Bitte versuchen Sie es später erneut."); } } // If we got this far, something failed, redisplay form var customer = _services.WorkContext.CurrentCustomer; model.Id = product.Id; model.ProductName = product.GetLocalized(x => x.Name); model.ProductSeName = product.GetSeName(); model.DisplayCaptcha = _captchaSettings.Enabled && _captchaSettings.ShowOnAskQuestionPage; return View(model); }
public ActionResult AskQuestionButton(int id) { if (!_catalogSettings.AskQuestionEnabled) return Content(""); var model = new ProductAskQuestionModel() { Id = id }; return PartialView(model); }