public void Should_have_error_when_yourEmailAddress_is_null_or_empty() { var model = new ProductEmailAFriendModel(); 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 ProductEmailAFriendModel(); model.FriendEmail = null; _validator.ShouldHaveValidationErrorFor(x => x.FriendEmail, model); model.FriendEmail = ""; _validator.ShouldHaveValidationErrorFor(x => x.FriendEmail, model); }
public ActionResult EmailAFriendSend(ProductEmailAFriendModel model, int id, bool captchaValid) { var product = _productService.GetProductById(id); if (product == null || product.Deleted || !product.Published || !_catalogSettings.EmailAFriendEnabled) return HttpNotFound(); //validate CAPTCHA if (_captchaSettings.Enabled && _captchaSettings.ShowOnEmailProductToFriendPage && !captchaValid) { ModelState.AddModelError("", T("Common.WrongCaptcha")); } //check whether the current customer is guest and ia allowed to email a friend if (_services.WorkContext.CurrentCustomer.IsGuest() && !_catalogSettings.AllowAnonymousUsersToEmailAFriend) { ModelState.AddModelError("", T("Products.EmailAFriend.OnlyRegisteredUsers")); } if (ModelState.IsValid) { //email _workflowMessageService.SendProductEmailAFriendMessage(_services.WorkContext.CurrentCustomer, _services.WorkContext.WorkingLanguage.Id, product, model.YourEmailAddress, model.FriendEmail, Core.Html.HtmlUtils.FormatText(model.PersonalMessage, false, true, false, false, false, false)); model.ProductId = product.Id; model.ProductName = product.GetLocalized(x => x.Name); model.ProductSeName = product.GetSeName(); //model.SuccessfullySent = true; //model.Result = T("Products.EmailAFriend.SuccessfullySent"); //return View(model); NotifySuccess(T("Products.EmailAFriend.SuccessfullySent")); return RedirectToRoute("Product", new { SeName = model.ProductSeName }); } //If we got this far, something failed, redisplay form model.ProductId = product.Id; model.ProductName = product.GetLocalized(x => x.Name); model.ProductSeName = product.GetSeName(); model.DisplayCaptcha = _captchaSettings.Enabled && _captchaSettings.ShowOnEmailProductToFriendPage; return View(model); }
public ActionResult EmailAFriend(int id) { var product = _productService.GetProductById(id); if (product == null || product.Deleted || !product.Published || !_catalogSettings.EmailAFriendEnabled) return HttpNotFound(); var model = new ProductEmailAFriendModel(); model.ProductId = product.Id; model.ProductName = product.GetLocalized(x => x.Name); model.ProductSeName = product.GetSeName(); model.YourEmailAddress = _services.WorkContext.CurrentCustomer.Email; model.DisplayCaptcha = _captchaSettings.Enabled && _captchaSettings.ShowOnEmailProductToFriendPage; return View(model); }
public ActionResult EmailAFriendButton(int id) { if (!_catalogSettings.EmailAFriendEnabled) return Content(""); var model = new ProductEmailAFriendModel() { ProductId = id }; return PartialView(model); }
public void Should_not_have_error_when_yourEmailAddress_is_correct_format() { var model = new ProductEmailAFriendModel(); model.YourEmailAddress = "*****@*****.**"; _validator.ShouldNotHaveValidationErrorFor(x => x.YourEmailAddress, model); }
public void Should_have_error_when_friendEmail_is_wrong_format() { var model = new ProductEmailAFriendModel(); model.FriendEmail = "adminexample.com"; _validator.ShouldHaveValidationErrorFor(x => x.FriendEmail, model); }