Example #1
0
        public ActionResult Edit(int id, TripEdit model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            if (model.TripId != id)
            {
                ModelState.AddModelError("", "ID Mismatch");
                return(View(model));
            }

            var service = CreateTripService();

            if (service.UpdateTrip(model))
            {
                TempData["SaveResult"] = "Your trip was updated.";
                return(RedirectToAction("Index"));
            }

            ModelState.AddModelError("", "Your trip could not be updated.");

            return(View());
        }
Example #2
0
        public ActionResult Edit(int id)
        {
            var service = CreateService();
            var detail  = service.GetTripById(id);
            var model   =
                new TripEdit
            {
                TripID     = detail.TripID,
                TripName   = detail.TripName,
                DepartDate = detail.DepartDate,
                Returndate = detail.ReturnDate
            };

            return(View(model));
        }
Example #3
0
        public bool UpdateTrip(TripEdit model)
        {
            using (var ctx = new ApplicationDbContext())
            {
                var entity =
                    ctx
                    .Trips
                    .Single(e => e.TripID == model.TripID && e.OwnerID == _userID);
                entity.TripName   = model.TripName;
                entity.DepartDate = model.DepartDate;
                entity.ReturnDate = model.Returndate;

                return(ctx.SaveChanges() == 1);
            }
        }
Example #4
0
        public IHttpActionResult Put(TripEdit model)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            var noteService = new TripService(Guid.Parse(User.Identity.GetUserId()));
            var temp        = noteService.GetTripById(model.TripID);

            if (temp == null)
            {
                return(NotFound());
            }

            return(Ok(noteService.EditTrip(model)));
        }
Example #5
0
        // Update
        public IHttpActionResult Put(TripEdit trip)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var service = CreateTripService();

            if (!service.UpdateTrip(trip))
            {
                return(InternalServerError());
            }

            return(Ok());
        }
Example #6
0
        public ActionResult Edit(int id)
        {
            var service = CreateTripService();
            var detail  = service.GetTripById(id);
            var model   =
                new TripEdit
            {
                TripId              = detail.TripId,
                TripStartDate       = detail.TripStartDate,
                TripEndDate         = detail.TripEndDate,
                Places              = detail.Places,
                MemoriesDescription = detail.MemoriesDescription
            };

            return(View(model));
        }
Example #7
0
        public bool UpdateTrip(TripEdit model)
        {
            using (var ctx = new ApplicationDbContext())
            {
                var entity =
                    ctx
                    .Trips
                    .Single(e => e.TripId == model.TripId && e.UserId == _userId);

                entity.TripStartDate       = model.TripStartDate;
                entity.TripEndDate         = model.TripEndDate;
                entity.Country.CountryName = model.CountryName;
                entity.Places = model.Places;
                entity.MemoriesDescription = model.MemoriesDescription;

                return(ctx.SaveChanges() == 1);
            }
        }
Example #8
0
        //Get : Trip/Edit/{id}
        public ActionResult Edit(int id)
        {
            var service = CreateTripService();
            var detail  = service.GetTripById(id);
            var model   =
                new TripEdit
            {
                TripId               = detail.TripId,
                StartTime            = detail.StartTime,
                BuddyId              = detail.BuddyId,
                VolunteerId          = detail.VolunteerId,
                StartLocation        = detail.StartLocation,
                ProjectedEndLocation = detail.ProjectedEndLocation,
                EndLocation          = detail.EndLocation,
                EndTime              = detail.EndTime
            };

            return(View(model));
        }
Example #9
0
        // Edit Trip

        public ActionResult Edit(int id)
        {
            var service = TripCreateService();
            var detail  = service.GetTripById(id);
            var model   =
                new TripEdit
            {
                TripID      = detail.TripID,
                Price       = detail.Price,
                TripTime    = detail.TripTime,
                Origin      = detail.Origin,
                Destination = detail.Destination,
                Hours       = detail.Hours,
                Minutes     = detail.Minutes,
                Seats       = detail.Seats,
                CarID       = detail.CarID,
                DriverID    = detail.DriverID
            };

            return(View(model));
        }
Example #10
0
        //Edit Trips
        public bool EditTrip(TripEdit model)
        {
            using (var ctx = new ApplicationDbContext())
            {
                var entity =
                    ctx
                    .Trips
                    .Single(e => e.TripID == model.TripID);


                entity.Price       = model.Price;
                entity.TripTime    = model.TripTime;
                entity.Origin      = model.Origin;
                entity.Destination = model.Destination;
                entity.Hours       = model.Hours;
                entity.Minutes     = model.Minutes;
                entity.Seats       = model.Seats;
                entity.CarID       = model.CarID;
                entity.DriverID    = model.DriverID;

                return(ctx.SaveChanges() == 1);
            }
        }
Example #11
0
        public bool UpdateTrip(TripEdit model)
        {
            using (var ctx = new ApplicationDbContext())
            {
                var entity =
                    ctx
                    .Trips
                    .SingleOrDefault(t => t.TripId == model.TripId);

                entity.StartTime = model.StartTime;
                entity.BuddyId   = model.BuddyId;

                entity.VolunteerId          = model.VolunteerId;
                entity.StartLocation        = model.StartLocation;
                entity.ProjectedEndLocation = model.ProjectedEndLocation;
                entity.EndLocation          = model.EndLocation;
                entity.EndTime = model.EndTime;
                if (!ctx.ChangeTracker.HasChanges())
                {
                    return(true);
                }
                return(ctx.SaveChanges() == 1);
            }
        }
Example #12
0
 public bool EditTrip(TripEdit model)
 {
     throw new NotImplementedException();
 }