コード例 #1
0
        public ActionResult DeleteConfirmed(int id)
        {
            Bookings bookings = db.Bookings.Find(id);

            db.Bookings.Remove(bookings);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
コード例 #2
0
 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));
 }
コード例 #3
0
        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));
        }
コード例 #4
0
        // 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));
        }
コード例 #5
0
        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"));
        }