Skip to content

Open-source eCommerce platform for C# and ASP.NET Core 10 with MongoDB. Build multi-store shops and multi-vendor marketplaces with B2B/B2C, REST API, plugins, Vue 3 and Docker.

Update ContactVendor

KrzysztofPajak7c096f700ebe
diff --git a/src/Web/Grand.Web/Controllers/VendorController.cs b/src/Web/Grand.Web/Controllers/VendorController.cs
index 4b6f34529..cf2b3de9a 100644
--- a/src/Web/Grand.Web/Controllers/VendorController.cs
+++ b/src/Web/Grand.Web/Controllers/VendorController.cs
@@ -26,6 +26,7 @@ using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.DependencyInjection;
using System;
+using System.Linq;
using System.Threading.Tasks;
namespace Grand.Web.Controllers
@@ -405,11 +406,11 @@ namespace Grand.Web.Controllers
public virtual async Task<IActionResult> ContactVendor(ContactVendorModel model, bool captchaValid)
{
if (!_vendorSettings.AllowCustomersToContactVendors)
- return RedirectToRoute("HomePage");
+ return Content("");
var vendor = await _vendorService.GetVendorById(model.VendorId);
if (vendor == null || !vendor.Active || vendor.Deleted)
- return RedirectToRoute("HomePage");
+ return Content("");
//validate CAPTCHA
if (_captchaSettings.Enabled && _captchaSettings.ShowOnContactUsPage && !captchaValid)
@@ -422,11 +423,14 @@ namespace Grand.Web.Controllers
if (ModelState.IsValid)
{
model = await _mediator.Send(new ContactVendorSendCommand() { Model = model, Vendor = vendor, Store = _workContext.CurrentStore, IpAddress = HttpContext.Connection?.RemoteIpAddress?.ToString() });
- return View(model);
+ return Json(model);
}
model.DisplayCaptcha = _captchaSettings.Enabled && _captchaSettings.ShowOnContactUsPage;
- return View(model);
+ model.Result = string.Join(",", ModelState.Values.SelectMany(v => v.Errors).Select(x => x.ErrorMessage));
+ model.SuccessfullySent = false;
+
+ return Json(model);
}
#endregion
}