public void Should_not_have_error_when_yourEmailAddress_is_correct_format()
        {
            var model = new WishlistEmailAFriendModel();

            model.YourEmailAddress = "*****@*****.**";
            _validator.ShouldNotHaveValidationErrorFor(x => x.YourEmailAddress, model);
        }
        public void Should_have_error_when_friendEmail_is_wrong_format()
        {
            var model = new WishlistEmailAFriendModel();

            model.FriendEmail = "adminexample.com";
            _validator.ShouldHaveValidationErrorFor(x => x.FriendEmail, model);
        }
Ejemplo n.º 3
0
        public virtual IActionResult EmailWishlist([FromServices] CaptchaSettings captchaSettings)
        {
            if (!_permissionService.Authorize(StandardPermissionProvider.EnableWishlist) || !_shoppingCartSettings.EmailWishlistEnabled)
            {
                return(RedirectToRoute("HomePage"));
            }

            var cart = _workContext.CurrentCustomer.ShoppingCartItems
                       .Where(sci => sci.ShoppingCartType == ShoppingCartType.Wishlist)
                       .LimitPerStore(_storeContext.CurrentStore.Id)
                       .ToList();

            if (!cart.Any())
            {
                return(RedirectToRoute("HomePage"));
            }

            var model = new WishlistEmailAFriendModel
            {
                YourEmailAddress = _workContext.CurrentCustomer.Email,
                DisplayCaptcha   = captchaSettings.Enabled && captchaSettings.ShowOnEmailWishlistToFriendPage
            };

            return(View(model));
        }
        public void Should_have_error_when_yourEmailAddress_is_null_or_empty()
        {
            var model = new WishlistEmailAFriendModel();

            model.YourEmailAddress = null;
            _validator.ShouldHaveValidationErrorFor(x => x.YourEmailAddress, model);
            model.YourEmailAddress = "";
            _validator.ShouldHaveValidationErrorFor(x => x.YourEmailAddress, model);
        }
        public void Should_have_error_when_friendEmail_is_null_or_empty()
        {
            var model = new WishlistEmailAFriendModel();

            model.FriendEmail = null;
            _validator.ShouldHaveValidationErrorFor(x => x.FriendEmail, model);
            model.FriendEmail = "";
            _validator.ShouldHaveValidationErrorFor(x => x.FriendEmail, model);
        }
Ejemplo n.º 6
0
        public void ShouldNotHaveErrorWhenYourEmailAddressIsCorrectFormat()
        {
            var model = new WishlistEmailAFriendModel
            {
                YourEmailAddress = "*****@*****.**"
            };

            _validator.TestValidate(model).ShouldNotHaveValidationErrorFor(x => x.YourEmailAddress);
        }
Ejemplo n.º 7
0
        public void ShouldHaveErrorWhenFriendEmailIsWrongFormat()
        {
            var model = new WishlistEmailAFriendModel
            {
                FriendEmail = "adminexample.com"
            };

            _validator.TestValidate(model).ShouldHaveValidationErrorFor(x => x.FriendEmail);
        }
Ejemplo n.º 8
0
        public void Should_have_error_when_yourEmailAddress_is_wrong_format()
        {
            var model = new WishlistEmailAFriendModel
            {
                YourEmailAddress = "adminexample.com"
            };

            _validator.ShouldHaveValidationErrorFor(x => x.YourEmailAddress, model);
        }
Ejemplo n.º 9
0
        public void Should_not_have_error_when_friendEmail_is_correct_format()
        {
            var model = new WishlistEmailAFriendModel
            {
                FriendEmail = "*****@*****.**"
            };

            _validator.ShouldNotHaveValidationErrorFor(x => x.FriendEmail, model);
        }
        public void ShouldHaveErrorWhenYourEmailAddressIsWrongFormat()
        {
            var model = new WishlistEmailAFriendModel
            {
                YourEmailAddress = "adminexample.com"
            };

            _validator.ShouldHaveValidationErrorFor(x => x.YourEmailAddress, model);
        }
        public void ShouldNotHaveErrorWhenFriendEmailIsCorrectFormat()
        {
            var model = new WishlistEmailAFriendModel
            {
                FriendEmail = "*****@*****.**"
            };

            _validator.ShouldNotHaveValidationErrorFor(x => x.FriendEmail, model);
        }
Ejemplo n.º 12
0
        public void ShouldHaveErrorWhenYourEmailAddressIsNullOrEmpty()
        {
            var model = new WishlistEmailAFriendModel
            {
                YourEmailAddress = null
            };

            _validator.TestValidate(model).ShouldHaveValidationErrorFor(x => x.YourEmailAddress);
            model.YourEmailAddress = string.Empty;
            _validator.TestValidate(model).ShouldHaveValidationErrorFor(x => x.YourEmailAddress);
        }
Ejemplo n.º 13
0
        public void ShouldHaveErrorWhenFriendEmailIsNullOrEmpty()
        {
            var model = new WishlistEmailAFriendModel
            {
                FriendEmail = null
            };

            _validator.TestValidate(model).ShouldHaveValidationErrorFor(x => x.FriendEmail);
            model.FriendEmail = string.Empty;
            _validator.TestValidate(model).ShouldHaveValidationErrorFor(x => x.FriendEmail);
        }
Ejemplo n.º 14
0
        public virtual IActionResult EmailWishlistSend(WishlistEmailAFriendModel model, bool captchaValid,
                                                       [FromServices] IWorkflowMessageService workflowMessageService,
                                                       [FromServices] CaptchaSettings captchaSettings)
        {
            if (!_permissionService.Authorize(StandardPermissionProvider.EnableWishlist) || !_shoppingCartSettings.EmailWishlistEnabled)
            {
                return(RedirectToRoute("HomePage"));
            }

            var cart = _workContext.CurrentCustomer.ShoppingCartItems
                       .Where(sci => sci.ShoppingCartType == ShoppingCartType.Wishlist)
                       .LimitPerStore(_storeContext.CurrentStore.Id)
                       .ToList();

            if (!cart.Any())
            {
                return(RedirectToRoute("HomePage"));
            }

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

            //check whether the current customer is guest and ia allowed to email wishlist
            if (_workContext.CurrentCustomer.IsGuest() && !_shoppingCartSettings.AllowAnonymousUsersToEmailWishlist)
            {
                ModelState.AddModelError("", _localizationService.GetResource("Wishlist.EmailAFriend.OnlyRegisteredUsers"));
            }

            if (ModelState.IsValid)
            {
                //email
                workflowMessageService.SendWishlistEmailAFriendMessage(_workContext.CurrentCustomer,
                                                                       _workContext.WorkingLanguage.Id, model.YourEmailAddress,
                                                                       model.FriendEmail, Core.Html.HtmlHelper.FormatText(model.PersonalMessage, false, true, false, false, false, false));

                model.SuccessfullySent = true;
                model.Result           = _localizationService.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));
        }
Ejemplo n.º 15
0
        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));
        }
Ejemplo n.º 16
0
        public virtual async Task <IActionResult> EmailWishlist([FromServices] CaptchaSettings captchaSettings)
        {
            if (!await _permissionService.Authorize(StandardPermissionProvider.EnableWishlist) || !_shoppingCartSettings.EmailWishlistEnabled)
            {
                return(RedirectToRoute("HomePage"));
            }

            var cart = _shoppingCartService.GetShoppingCart(_storeContext.CurrentStore.Id, ShoppingCartType.Wishlist);

            if (!cart.Any())
            {
                return(RedirectToRoute("HomePage"));
            }

            var model = new WishlistEmailAFriendModel {
                YourEmailAddress = _workContext.CurrentCustomer.Email,
                DisplayCaptcha   = captchaSettings.Enabled && captchaSettings.ShowOnEmailWishlistToFriendPage
            };

            return(View(model));
        }