public ActionResult AddTrip(Trip trip)
 {
     //Add trip to database
     tripRepository.Add(trip);
     tripRepository.Commit();
     return RedirectToAction("Index");
 }
 public void EditTripShouldReturnView()
 {
     TripController controller = new TripController(repo);
     Trip trip4 = new Trip() { TripID = 4, DestinationID = 3, StartDate = new DateTime(2005, 3, 1), EndDate = new DateTime(2005, 3, 4)};
     ViewResult result = controller.EditTrip(trip4) as ViewResult;
     Assert.IsNotNull(result);
 }
        public ActionResult EditTripInDatabase(Trip trip)
        {
            Trip oldTrip = tripRepository.FindBy(T => T.TripID == trip.TripID).Single();
            oldTrip.StartDate = trip.StartDate;
            oldTrip.EndDate = trip.EndDate;
            oldTrip.DestinationID = trip.DestinationID;
            tripRepository.Commit();

            return RedirectToAction("Index");
        }
 public void EditTripInDatabaseShouldChangePreviouslyAddedTrip()
 {
     TripController controller = new TripController(repo);
     Trip trip2changed = new Trip() { TripID = 2, DestinationID = 1, StartDate = new DateTime(2013, 12, 1), EndDate = new DateTime(2013, 12, 3) };
     controller.EditTripInDatabase(trip2changed);
     ViewResult result = controller.Trips() as ViewResult;
     Assert.IsNotNull(result);
     IEnumerable<Trip> model = result.Model as IEnumerable<Trip>;
     Assert.AreEqual(2, model.Count());
     Trip temp = model.ElementAt(1);
     Assert.AreEqual(trip2changed.TripID, temp.TripID);
     Assert.AreEqual(trip2changed.DestinationID, temp.DestinationID);
     Assert.AreEqual(trip2changed.StartDate, temp.StartDate);
     Assert.AreEqual(trip2changed.EndDate, temp.EndDate);
 }
 public ActionResult EditTrip(Trip trip)
 {
     return View(trip);
 }
 // GET: /Trip/DeleteTrip
 public ActionResult DeleteTrip(Trip trip)
 {
     tripRepository.Remove(trip);
     tripRepository.Commit();
     return RedirectToAction("Index");
 }
 public void shouldAddNewTripToRepository()
 {
     TripController controller = new TripController(repo);
     Trip trip3 = new Trip() { TripID = 3, DestinationID = 1, StartDate = new DateTime(2013, 1, 1), EndDate = new DateTime(2013, 2, 1)};
     controller.AddTrip(trip3);
     ViewResult result = controller.Trips() as ViewResult;
     Assert.IsNotNull(result);
     IEnumerable<Trip> model = result.Model as IEnumerable<Trip>;
     Assert.AreEqual(3, model.Count());
     Assert.IsTrue(model.Contains(trip3));
 }