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.

Minor fix - Wishlist - EmailAFriend - return JSON model

KrzysztofPajak50962e6f332a
diff --git a/src/Web/Grand.Web/Controllers/WishlistController.cs b/src/Web/Grand.Web/Controllers/WishlistController.cs
index b19a19b5c..093d0331f 100644
--- a/src/Web/Grand.Web/Controllers/WishlistController.cs
+++ b/src/Web/Grand.Web/Controllers/WishlistController.cs
@@ -204,11 +204,11 @@ namespace Grand.Web.Controllers
[FromServices] CaptchaSettings captchaSettings)
{
if (!await _permissionService.Authorize(StandardPermission.EnableWishlist) || !_shoppingCartSettings.EmailWishlistEnabled)
- return RedirectToRoute("HomePage");
+ return Content("");
var cart = _shoppingCartService.GetShoppingCart(_workContext.CurrentStore.Id, ShoppingCartType.Wishlist);
if (!cart.Any())
- return RedirectToRoute("HomePage");
+ return Content("");
//validate CAPTCHA
if (captchaSettings.Enabled && captchaSettings.ShowOnEmailWishlistToFriendPage && !captchaValid)
@@ -232,12 +232,14 @@ namespace Grand.Web.Controllers
model.SuccessfullySent = true;
model.Result = _translationService.GetResource("Wishlist.EmailAFriend.SuccessfullySent");
- return View(model);
+ return Json(model);
}
//If we got this far, something failed, redisplay form
model.DisplayCaptcha = captchaSettings.Enabled && captchaSettings.ShowOnEmailWishlistToFriendPage;
- return View(model);
+ model.Result = string.Join(", ", ModelState.Values.SelectMany(v => v.Errors).Select(x => x.ErrorMessage));
+
+ return Json(model);
}
#endregion
diff --git a/src/Web/Grand.Web/Models/ShoppingCart/WishlistEmailAFriendModel.cs b/src/Web/Grand.Web/Models/ShoppingCart/WishlistEmailAFriendModel.cs
index cd5781c7f..a07f56f2b 100644
--- a/src/Web/Grand.Web/Models/ShoppingCart/WishlistEmailAFriendModel.cs
+++ b/src/Web/Grand.Web/Models/ShoppingCart/WishlistEmailAFriendModel.cs
@@ -18,5 +18,6 @@ namespace Grand.Web.Models.ShoppingCart
public string Result { get; set; }
public bool DisplayCaptcha { get; set; }
+
}
}
\ No newline at end of file