public void Should_have_error_when_fullName_is_null_or_empty()
 {
     var model = new ContactUsModel();
     model.FullName = null;
     _validator.ShouldHaveValidationErrorFor(x => x.FullName, model);
     model.FullName = "";
     _validator.ShouldHaveValidationErrorFor(x => x.FullName, model);
 }
 public void Should_have_error_when_additional_comments_is_null_or_empty()
 {
     var model = new ContactUsModel();
     model.AdditionalComments = null;
     _validator.ShouldHaveValidationErrorFor(x => x.AdditionalComments, model);
     model.AdditionalComments = "";
     _validator.ShouldHaveValidationErrorFor(x => x.AdditionalComments, model);
 }
 public void Should_have_error_when_buyer_email_is_null_or_empty()
 {
     var model = new ContactUsModel();
     model.BuyerEmail = null;
     _validator.ShouldHaveValidationErrorFor(x => x.BuyerEmail, model);
     model.BuyerEmail = "";
     _validator.ShouldHaveValidationErrorFor(x => x.BuyerEmail, model);
 }
 public void Should_have_error_when_accounting_contact_is_null_or_empty()
 {
     var model = new ContactUsModel();
     model.AccountingContact = null;
     _validator.ShouldHaveValidationErrorFor(x => x.AccountingContact, model);
     model.AccountingContact = "";
     _validator.ShouldHaveValidationErrorFor(x => x.AccountingContact, model);
 }
 public void Should_have_error_when_business_address_is_null_or_empty()
 {
     var model = new ContactUsModel();
     model.BusinessAddress = null;
     _validator.ShouldHaveValidationErrorFor(x => x.BusinessAddress, model);
     model.BusinessAddress = "";
     _validator.ShouldHaveValidationErrorFor(x => x.BusinessAddress, model);
 }
 public void Should_have_error_when_enquiry_is_null_or_empty()
 {
     var model = new ContactUsModel();
     model.Enquiry = null;
     _validator.ShouldHaveValidationErrorFor(x => x.Enquiry, model);
     model.Enquiry = "";
     _validator.ShouldHaveValidationErrorFor(x => x.Enquiry, model);
 }
 public void Should_have_error_when_state_is_null_or_empty()
 {
     var model = new ContactUsModel();
     model.StateProvince = null;
     _validator.ShouldHaveValidationErrorFor(x => x.StateProvince, model);
     model.StateProvince = "";
     _validator.ShouldHaveValidationErrorFor(x => x.StateProvince, model);
 }
 public ActionResult ContactUs()
 {
     var model = new ContactUsModel()
     {
         Email = _workContext.CurrentCustomer.Email,
         FullName = _workContext.CurrentCustomer.GetFullName(),
         DisplayCaptcha = _captchaSettings.Enabled && _captchaSettings.ShowOnContactUsPage
     };
     return View(model);
 }
Пример #9
0
 //contact us page
 public ActionResult ContactUs()
 {
     var model = new ContactUsModel()
     {
         Email = _workContext.CurrentCustomer.Email,
         FullName = _workContext.CurrentCustomer.GetFullName()
     };
     return View(model);
 }
 public void Should_not_have_error_when_key_interest_is_specified()
 {
     var model = new ContactUsModel();
     model.KeyInterest = "Some key interest";
     _validator.ShouldNotHaveValidationErrorFor(x => x.KeyInterest, model);
 }
 public void Should_not_have_error_when_phonenumber_is_specified()
 {
     var model = new ContactUsModel();
     model.BusinessPhoneNumber = "Texas";
     _validator.ShouldNotHaveValidationErrorFor(x => x.BusinessPhoneNumber, model);
 }
 public void Should_not_have_error_when_established_is_specified()
 {
     var model = new ContactUsModel();
     model.Established = "something :|";
     _validator.ShouldNotHaveValidationErrorFor(x => x.Established, model);
 }
 public void Should_not_have_error_when_home_address_is_specified()
 {
     var model = new ContactUsModel();
     model.BusinessAddress = "This is an address";
     _validator.ShouldNotHaveValidationErrorFor(x => x.HomeAddress, model);
 }
 public void Should_not_have_error_when_country_is_specified()
 {
     var model = new ContactUsModel();
     model.Country = "Some country";
     _validator.ShouldNotHaveValidationErrorFor(x => x.Country, model);
 }
 public void Should_not_have_error_when_company_name_is_specified()
 {
     var model = new ContactUsModel();
     model.CompanyName = "Company Co";
     _validator.ShouldNotHaveValidationErrorFor(x => x.CompanyName, model);
 }
 public void Should_not_have_error_when_additional_comments_is_specified()
 {
     var model = new ContactUsModel();
     model.AdditionalComments = "please call me back";
     _validator.ShouldNotHaveValidationErrorFor(x => x.AdditionalComments, model);
 }
 public void Should_have_error_when_buyer_email_is_wrong_format()
 {
     var model = new ContactUsModel();
     model.BuyerEmail = "adminexample.com";
     _validator.ShouldHaveValidationErrorFor(x => x.BuyerEmail, model);
 }
 public void Should_not_have_error_when_state_is_specified()
 {
     var model = new ContactUsModel();
     model.StateProvince = "Texas";
     _validator.ShouldNotHaveValidationErrorFor(x => x.StateProvince, model);
 }
Пример #19
0
        public ActionResult ContactUsSend(ContactUsModel model, bool captchaValid)
        {
            string email = model.ActgEmail.Trim();
            string fullName = model.FirstName;
            string subject = string.Format(_localizationService.GetResource("ContactUs.EmailSubject"), _storeContext.CurrentStore.GetLocalized(x => x.Name));

            var emailAccount = _emailAccountService.GetEmailAccountById(_emailAccountSettings.DefaultEmailAccountId);
            if (emailAccount == null)
                emailAccount = _emailAccountService.GetAllEmailAccounts().FirstOrDefault();
            if (emailAccount == null)
                throw new Exception("No email account could be loaded");

            string emailContent = "Business Name: " + model.CompanyName +
                "\nBusiness Address: " + model.BusinessAddress +
                "\nCity: " + model.City +
                "\nState/Province: " + model.StateProvince +
                "\nZipcode: " + model.ZipCode +
                "\nAccounting Contact: " + model.ActgEmail +
                "\nPhone: " + model.BusinessPhoneNumber +
                "\nFax: " + model.FaxNumber +
                "\nCountry: " + model.Country +
                "\n\nPersonal Owner or Stockholder Information\n" +
                "\nFull name: " + model.FirstName +
                "\nHome Address: " + model.HomeAddress +
                "\nTitle: " + model.Title +
                "\nHome Phone: " + model.HomePhoneNumber +
                "\nKey interest: " + model.KeyInterest +
                "\nAdditional Comments: " + model.AdditionalComments;

            string from = null;
            string fromName = null;
            string body = Core.Html.HtmlHelper.FormatText(emailContent, false, true, false, false, false, false);
            //required for some SMTP servers
            if (_commonSettings.UseSystemEmailForContactUsForm)
            {
                from = emailAccount.Email;
                fromName = emailAccount.DisplayName;
                body = string.Format("<strong>From</strong>: {0} - {1}<br /><br />{2}",
                    Server.HtmlEncode(fullName),
                    Server.HtmlEncode(email), body);
            }
            else
            {
                from = email;
                fromName = fullName;
            }
            _queuedEmailService.InsertQueuedEmail(new QueuedEmail()
            {
                From = from,
                FromName = fromName,
                To = emailAccount.Email,
                ToName = emailAccount.DisplayName,
                ReplyTo = email,
                ReplyToName = fullName,
                Priority = 5,
                Subject = subject,
                Body = body,
                CreatedOnUtc = DateTime.UtcNow,
                EmailAccountId = emailAccount.Id
            });

            model.SuccessfullySent = true;
            model.Result = _localizationService.GetResource("ContactUs.YourEnquiryHasBeenSent");

            //activity log
            _customerActivityService.InsertActivity("PublicStore.ContactUs", _localizationService.GetResource("ActivityLog.PublicStore.ContactUs"));

            return View(model);

            //model.DisplayCaptcha = _captchaSettings.Enabled && _captchaSettings.ShowOnContactUsPage;
            //return View(model);
        }
 public void Should_not_have_error_when_email_is_correct_format()
 {
     var model = new ContactUsModel();
     model.Email = "*****@*****.**";
     _validator.ShouldNotHaveValidationErrorFor(x => x.Email, model);
 }
Пример #21
0
        public ActionResult ContactUsSend(ContactUsModel model)
        {
            //ajax form
            if (ModelState.IsValid)
            {
                string email = model.Email.Trim();
                string fullName = model.FullName;
                string subject = string.Format("{0}. {1}", _storeInformationSettings.StoreName, "Contact us");

                var emailAccount = _emailAccountService.GetEmailAccountById(_emailAccountSettings.DefaultEmailAccountId);

                string from = null;
                string fromName = null;
                string body = Core.Html.HtmlHelper.FormatText(model.Enquiry, false, true, false, false, false, false);
                //required for some SMTP servers
                if (_commonSettings.UseSystemEmailForContactUsForm)
                {
                    from = emailAccount.Email;
                    fromName = emailAccount.DisplayName;
                    body = string.Format("<b>From</b>: {0} - {1}<br /><br />{2}", Server.HtmlEncode(fullName), Server.HtmlEncode(email), body);
                }
                else
                {
                    from = email;
                    fromName = fullName;
                }
                _queuedEmailService.InsertQueuedEmail(new QueuedEmail()
                    {
                        From = from,
                        FromName = fromName,
                        To = emailAccount.Email,
                        ToName = emailAccount.DisplayName,
                        Priority = 5,
                        Subject = subject,
                        Body = body,
                        CreatedOnUtc = DateTime.UtcNow,
                        EmailAccountId = emailAccount.Id
                    });

                return Content(_localizationService.GetResource("ContactUs.YourEnquiryHasBeenSent"));
            }

            return Content(ModelState.Values.FirstOrDefault().Errors.FirstOrDefault().ErrorMessage);
        }
 public void Should_not_have_error_when_fullName_is_specified()
 {
     var model = new ContactUsModel();
     model.FullName = "John Smith";
     _validator.ShouldNotHaveValidationErrorFor(x => x.FullName, model);
 }
 public void Should_not_have_error_when_title_is_specified()
 {
     var model = new ContactUsModel();
     model.Title = "some title";
     _validator.ShouldNotHaveValidationErrorFor(x => x.Title, model);
 }
 public void Should_not_have_error_when_accounting_contact_is_specified()
 {
     var model = new ContactUsModel();
     model.AccountingContact = "Some contact";
     _validator.ShouldNotHaveValidationErrorFor(x => x.AccountingContact, model);
 }
 public void Should_not_have_error_when_enquiry_is_specified()
 {
     var model = new ContactUsModel();
     model.Enquiry = "please call me back";
     _validator.ShouldNotHaveValidationErrorFor(x => x.Enquiry, model);
 }
 public void Should_not_have_error_when_type_of_business_is_specified()
 {
     var model = new ContactUsModel();
     model.TypeOfBusiness = "Some business type";
     _validator.ShouldNotHaveValidationErrorFor(x => x.TypeOfBusiness, model);
 }
Пример #27
0
        public ActionResult ContactUsSend(ContactUsModel model, bool captchaValid)
        {
            //validate CAPTCHA
            if (_captchaSettings.Enabled && _captchaSettings.ShowOnContactUsPage && !captchaValid)
            {
                ModelState.AddModelError("", _localizationService.GetResource("Common.WrongCaptcha"));
            }

            if (ModelState.IsValid)
            {
                string email = model.Email.Trim();
                string fullName = model.FullName;
                string subject = string.Format("{0}. {1}", _storeInformationSettings.StoreName, "Contact us");

                var emailAccount = _emailAccountService.GetEmailAccountById(_emailAccountSettings.DefaultEmailAccountId);

                string from = null;
                string fromName = null;
                string body = Core.Html.HtmlHelper.FormatText(model.Enquiry, false, true, false, false, false, false);
                //required for some SMTP servers
                if (_commonSettings.UseSystemEmailForContactUsForm)
                {
                    from = emailAccount.Email;
                    fromName = emailAccount.DisplayName;
                    body = string.Format("<b>From</b>: {0} - {1}<br /><br />{2}",
                        Server.HtmlEncode(fullName),
                        Server.HtmlEncode(email), body);
                }
                else
                {
                    from = email;
                    fromName = fullName;
                }
                _queuedEmailService.InsertQueuedEmail(new QueuedEmail()
                {
                    From = from,
                    FromName = fromName,
                    To = emailAccount.Email,
                    ToName = emailAccount.DisplayName,
                    Priority = 5,
                    Subject = subject,
                    Body = body,
                    CreatedOnUtc = DateTime.UtcNow,
                    EmailAccountId = emailAccount.Id
                });

                model.SuccessfullySent = true;
                model.Result = _localizationService.GetResource("ContactUs.YourEnquiryHasBeenSent");
                return View(model);
            }

            model.DisplayCaptcha = _captchaSettings.Enabled && _captchaSettings.ShowOnContactUsPage;
            return View(model);
        }
 public void Should_not_have_error_when_zipcode_is_specified()
 {
     var model = new ContactUsModel();
     model.ZipCode = "60201";
     _validator.ShouldNotHaveValidationErrorFor(x => x.ZipCode, model);
 }
        public ActionResult ContactUsSend(ContactUsModel model, bool captchaValid)
        {
            //validate CAPTCHA
            if (_captchaSettings.Enabled && _captchaSettings.ShowOnContactUsPage && !captchaValid)
            {
                ModelState.AddModelError("", _localizationService.GetResource("Common.WrongCaptcha"));
            }

            if (ModelState.IsValid)
            {
                string email = model.Email.Trim();
                string fullName = model.FullName;
                string subject = string.Format(_localizationService.GetResource("ContactUs.EmailSubject"), _storeContext.CurrentStore.GetLocalized(x => x.Name));

                var emailAccount = _emailAccountService.GetEmailAccountById(_emailAccountSettings.DefaultEmailAccountId);
                if (emailAccount == null)
                    emailAccount = _emailAccountService.GetAllEmailAccounts().FirstOrDefault();
                if (emailAccount == null)
                    throw new Exception("No email account could be loaded");

                string from = null;
                string fromName = null;
                string body = Core.Html.HtmlHelper.FormatText(model.Enquiry, false, true, false, false, false, false);
                //required for some SMTP servers
                if (_commonSettings.UseSystemEmailForContactUsForm)
                {
                    from = emailAccount.Email;
                    fromName = emailAccount.DisplayName;
                    body = string.Format("<strong>From</strong>: {0} - {1}<br /><br />{2}",
                        Server.HtmlEncode(fullName),
                        Server.HtmlEncode(email), body);
                }
                else
                {
                    from = email;
                    fromName = fullName;
                }
                _queuedEmailService.InsertQueuedEmail(new QueuedEmail()
                {
                    From = from,
                    FromName = fromName,
                    To = emailAccount.Email,
                    ToName = emailAccount.DisplayName,
                    ReplyTo = email,
                    ReplyToName = fullName,
                    Priority = 5,
                    Subject = subject,
                    Body = body,
                    CreatedOnUtc = DateTime.UtcNow,
                    EmailAccountId = emailAccount.Id
                });

                model.SuccessfullySent = true;
                model.Result = _localizationService.GetResource("ContactUs.YourEnquiryHasBeenSent");

                //activity log
                _customerActivityService.InsertActivity("PublicStore.ContactUs", _localizationService.GetResource("ActivityLog.PublicStore.ContactUs"));

                return View(model);
            }

            model.DisplayCaptcha = _captchaSettings.Enabled && _captchaSettings.ShowOnContactUsPage;
            return View(model);
        }
 public void Should_have_error_when_phonenumber_is_null_or_empty()
 {
     var model = new ContactUsModel();
     model.BusinessPhoneNumber = null;
     _validator.ShouldHaveValidationErrorFor(x => x.BusinessPhoneNumber, model);
     model.BusinessPhoneNumber = "";
     _validator.ShouldHaveValidationErrorFor(x => x.BusinessPhoneNumber, model);
 }