public ActionResult Create() { User trip_leader = get_current_user(); Trip new_trip = new Trip(trip_leader.UserID); TripDB.Add(new_trip); TripDB.Commit(); trip_leader.trips.Add(new_trip); UserDB.Attach(trip_leader); UserDB.Commit(); return(RedirectToAction("Details", new { id = new_trip.TripID })); }
public ActionResult Create(Trip trip, Guid userID) { if (ModelState.IsValid) { User trip_leader = UserDB.FindBy(x => x.UserID == userID).Single(); trip.TripID = Guid.NewGuid(); TripDB.Add(trip); trip.trip_leader = trip_leader; trip_leader.trips.Add(trip); UserDB.Attach(trip_leader); UserDB.Commit(); TripDB.Commit(); return(RedirectToAction("Index")); } return(View(trip)); }