Ejemplo n.º 1
0
        public virtual IActionResult ContactVendorSend(ContactVendorModel model, bool captchaValid)
        {
            if (!_vendorSettings.AllowCustomersToContactVendors)
            {
                return(RedirectToRoute("HomePage"));
            }

            var vendor = EngineContext.Current.Resolve <IVendorService>().GetVendorById(model.VendorId);

            if (vendor == null || !vendor.Active || vendor.Deleted)
            {
                return(RedirectToRoute("HomePage"));
            }

            //validate CAPTCHA
            if (_captchaSettings.Enabled && _captchaSettings.ShowOnContactUsPage && !captchaValid)
            {
                ModelState.AddModelError("", _captchaSettings.GetWrongCaptchaMessage(_localizationService));
            }

            model.VendorName = vendor.GetLocalized(x => x.Name);

            if (ModelState.IsValid)
            {
                model = _commonWebService.SendContactVendor(model, vendor);
                return(View(model));
            }

            model.DisplayCaptcha = _captchaSettings.Enabled && _captchaSettings.ShowOnContactUsPage;
            return(View(model));
        }