public virtual async Task <IActionResult> EmailWishlist(WishlistEmailAFriendModel model, bool captchaValid, [FromServices] IMessageProviderService messageProviderService, [FromServices] CaptchaSettings captchaSettings) { if (!await _permissionService.Authorize(StandardPermission.EnableWishlist) || !_shoppingCartSettings.EmailWishlistEnabled) { return(RedirectToRoute("HomePage")); } var cart = _shoppingCartService.GetShoppingCart(_workContext.CurrentStore.Id, ShoppingCartType.Wishlist); if (!cart.Any()) { return(RedirectToRoute("HomePage")); } //validate CAPTCHA if (captchaSettings.Enabled && captchaSettings.ShowOnEmailWishlistToFriendPage && !captchaValid) { ModelState.AddModelError("", captchaSettings.GetWrongCaptchaMessage(_translationService)); } //check whether the current customer is guest and ia allowed to email wishlist if (await _groupService.IsGuest(_workContext.CurrentCustomer) && !_shoppingCartSettings.AllowAnonymousUsersToEmailWishlist) { ModelState.AddModelError("", _translationService.GetResource("Wishlist.EmailAFriend.OnlyRegisteredUsers")); } if (ModelState.IsValid) { //email await messageProviderService.SendWishlistEmailAFriendMessage(_workContext.CurrentCustomer, _workContext.CurrentStore, _workContext.WorkingLanguage.Id, model.YourEmailAddress, model.FriendEmail, FormatText.ConvertText(model.PersonalMessage)); model.SuccessfullySent = true; model.Result = _translationService.GetResource("Wishlist.EmailAFriend.SuccessfullySent"); return(View(model)); } //If we got this far, something failed, redisplay form model.DisplayCaptcha = captchaSettings.Enabled && captchaSettings.ShowOnEmailWishlistToFriendPage; return(View(model)); }