/// <summary>
        /// Saves a new form record from the specified "Contact us" form data.
        /// </summary>
        /// <param name="message">The "Contact us" form data.</param>
        public void InsertContactUsFormItem(MessageModel message)
        {
            var item = new DancingGoatMvcContactUsItem
            {
                UserFirstName = message.FirstName,
                UserLastName = message.LastName,
                UserEmail = message.Email,
                UserMessage = message.MessageText,
            };

            item.Insert();
        }
        /// <summary>
        /// Creates a new form record from the specified "Contact us" form data, and returns it.
        /// </summary>
        /// <param name="message">The "Contact us" form data.</param>
        /// <returns>The form record created from the specified "Contact us" form data.</returns>
        public TestMvcDemoContactUsItem CreateContactUsFormItem(MessageModel message)
        {
            var item = new TestMvcDemoContactUsItem
            {
                UserFirstName = message.FirstName,
                UserLastName = message.LastName,
                UserEmail = message.Email,
                UserMessage = message.MessageText,
            };

            item.Insert();

            return item;
        }
        public ActionResult SendMessage(MessageModel message)
        {
            if (!ModelState.IsValid)
            {
                var model = GetIndexViewModel();
                model.Message = message;

                return View("Index", model);
            }

            try
            {
                mFormItemRepository.CreateContactUsFormItem(message);
            }
            catch
            {
                return View("Error");
            }

            return RedirectToAction("ThankYou");
        }
 /// <summary>
 /// Creates a new form record from the specified "Contact us" form data, and returns it.
 /// </summary>
 /// <param name="message">The "Contact us" form data.</param>
 /// <returns>The form record created from the specified "Contact us" form data.</returns>
 public abstract TestMvcDemoContactUsItem CreateContactUsFormItem(MessageModel message);
        public void SetUp()
        {
            Fake<CountryInfo, CountryInfoProvider>();
            Fake<StateInfo, StateInfoProvider>();
            Fake().DocumentType<Contact>(Contact.CLASS_NAME);

            var country = new CountryInfo { CountryName = "USA", CountryTwoLetterCode = "US" };
            var state = new StateInfo { StateName = "Illinois", StateDisplayName = "Illinois" };
            var contact = TreeNode.New<Contact>().With(x => x.Fields.Country = "USA;Illinois");

            var socialLinkRepository = Substitute.For<ISocialLinkRepository>();
            var cafeRepository = Substitute.For<ICafeRepository>();
            var contactRepository = Substitute.For<IContactRepository>();
            var countryRepository = Substitute.For<ICountryRepository>();
            var outputCacheDependencies = Substitute.For<IOutputCacheDependencies>();

            contactRepository.GetCompanyContact().Returns(contact);
            countryRepository.GetCountry(country.CountryName).Returns(country);
            countryRepository.GetState(state.StateName).Returns(state);

            mFormItemRepository = Substitute.For<IFormItemRepository>();
            mController = new ContactsController(cafeRepository, socialLinkRepository, contactRepository, mFormItemRepository, countryRepository, outputCacheDependencies);
            mMessageModel = CreateMessageModel();
        }