public ActionResult Update(int id, Contact contact)
 {
     var original = _repository.FindById<Contact>(id);
     original.EmailAddress = contact.EmailAddress;
     original.FirstName = contact.FirstName;
     original.LastName = contact.LastName;
     _repository.Commit();
     _appScope.AddSuccess("Contact successfully updated.");
     return RedirectToAction("Index");
 }
        public void TestCreateReturnsIndex()
        {
            // Assemble
            var scope = new Mock<IAppScope>();
            scope.SetupGet(x => x.IsXhr).Returns(false);
            var repo = new Mock<IRepository>();
            var controller = new ContactsController(repo.Object, scope.Object);

            // Act
            var contact = new Contact();
            var result = controller.Create(contact);

            // Assert
            var redirectToRouteResult = Assert.IsType<RedirectToRouteResult>(result);
            Assert.Equal("Index", redirectToRouteResult.RouteValues["action"]);
        }
 public ActionResult New()
 {
     var contact = new Contact();
     return View(contact);
 }
 public ActionResult Create(Contact contact)
 {
     _repository.Insert(contact);
     _appScope.AddSuccess("New contact was successfully created.");
     return RedirectToAction("Index");
 }