예제 #1
0
        public void CanFail3CreateContact()
        {
            IContactRecordRepository repo   = RepoFactory.CreateContactRecordRepo();
            ContactRecord            record = new ContactRecord()
            {
                Email   = "*****@*****.**",
                Name    = "TestContact",
                Message = "",
                Phone   = "701-701-7011"
            };

            var result = repo.Create(record);

            Assert.AreEqual(null, result);
        }
예제 #2
0
        public void CanCreate3Contact()
        {
            IContactRecordRepository repo   = RepoFactory.CreateContactRecordRepo();
            ContactRecord            record = new ContactRecord()
            {
                Email   = "*****@*****.**",
                Name    = "TestContact",
                Message = "Blah blah",
                Phone   = ""
            };

            var result = repo.Create(record);

            Assert.GreaterOrEqual(1, result.ContactRecordId);
            Assert.AreEqual(record, result);
        }
예제 #3
0
 public ActionResult Contact(ContactRecord model)
 {
     if (model.Email == null && model.Phone == null)
     {
         ModelState.AddModelError("Error", "Either Provide an Email or phone");
         return(View(model));
     }
     if (ModelState.IsValid)
     {
         IContactRecordRepository repo = RepoFactory.CreateContactRecordRepo();
         repo.Create(model);
         ModelState.AddModelError("Error", "Your response has been submitted");
         return(View(new ContactRecord()));
     }
     else
     {
         return(View(model));
     }
 }