public ActionResult DeleteConfirmed(int id) { Bookings bookings = db.Bookings.Find(id); db.Bookings.Remove(bookings); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Edit([Bind(Include = "BookingID,TripID,UserId,SeatId")] Bookings bookings) { if (ModelState.IsValid) { db.Entry(bookings).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(bookings)); }
public ActionResult Create([Bind(Include = "BookingID,TripID,UserId,SeatId")] Bookings bookings) { if (ModelState.IsValid) { db.Bookings.Add(bookings); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(bookings)); }
// GET: Bookings/Delete/5 public ActionResult Delete(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Bookings bookings = db.Bookings.Find(id); if (bookings == null) { return(HttpNotFound()); } return(View(bookings)); }
public ActionResult DeleteConfirmed(int id) { //Find booking on Database Bookings bookings = db.Bookings.Find(id); //Remove booking from database db.Bookings.Remove(bookings); //Release seat on the trip corresponding to the booking releaseSeat(bookings.SeatId, bookings.TripID); //increase the seats available for the trip db.Trips.Find(bookings.TripID).Seats++; db.SaveChanges(); //refund user for the canceled booking refundUser(bookings.TripID, bookings.UserId); return(RedirectToAction("Index")); }