Example #1
0
 public ActionResult Edit(User user)
 {
     if (ModelState.IsValid)
     {
         UserDB.Attach(user);
         UserDB.Commit();
         return(RedirectToAction("Index"));
     }
     return(View(user));
 }
Example #2
0
        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 }));
        }
Example #3
0
        private User CreateNewUser(dynamic me)
        {
            User new_user = new User(me.first_name, me.last_name, me.email);

            UserDB.Add(new_user);
            UserDB.Commit();

            Locker new_locker = new Locker(new_user.UserID);


            LockerDB.Add(new_locker);
            LockerDB.Commit();

            new_user.locker = new_locker;
            UserDB.Attach(new_user);
            UserDB.Commit();
            return(new_user);
        }
Example #4
0
        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));
        }