//    [HttpPost]
        // public ActionResult Edit([Bind(Include="BOOKINGID,SESSIONID,BOOKEDSEATS,Emailid")] Booking booking)
        public ActionResult Editdetails()
        {
            float price = 0;
              /// Booking booking = new Booking();
               Booking booking1=new Booking();
            Booking currentbooking = new Booking();
            Session session = new Session();
            if (Session["editdetails"] != null)
            {
               /* FormCollection form = (FormCollection)Session["editdetails"];
               string s= form.Get(0).ToString();
                int bookingid=int.Parse(form.Get(0).ToString());
                int sessionid = int.Parse(form.Get(1).ToString());
                int newseats = int.Parse(form.Get(2).ToString());
                string emailid= form.Get(3).ToString();*/
                booking1= (Booking)Session["editdetails"];
                int bookingid = (int)booking1.BOOKINGID;
                int sessionid = (int)booking1.SESSIONID;
                int newseats = (int)booking1.BOOKEDSEATS;
                string emailid = (string)booking1.Emailid;
                foreach (Booking b in db.Bookings)
                {
                    if (bookingid == (int)b.BOOKINGID)
                    {
                        currentbooking=b;
                        break;
                    }
                }

                foreach (Session sess in db.Sessions)
                {
                    if (sessionid== (int)sess.SESSIONID)
                    {
                        session=sess;
                        break;
                    }
                }

                int currentseats = (int)currentbooking.BOOKEDSEATS;

                if (newseats > 20)
                {
                    ModelState.AddModelError("Bookingerror", "bookeseats cannot be greater than maximum seats ");
                }

                else if (newseats <= currentseats || newseats <= 20)
                {

                  float price1= (float)session.Movie.Price;
                  currentbooking.PRICE = price1 * newseats;
                    //seats are added to booking
                    if (currentseats < newseats)
                    {
                        session.SEAT = (int)session.SEAT - (newseats - currentseats);
                        currentbooking.BOOKEDSEATS = newseats;
                    }
                        //new seats are less means seats deleted from booking
                    else if (currentseats > newseats)
                    {
                        session.SEAT = (int)session.SEAT + (currentseats - newseats);
                        currentbooking.BOOKEDSEATS = newseats;

                    }

                }

                if (ModelState.IsValid)
                {
                    db.Entry(currentbooking).State = EntityState.Modified;
                    db.Entry(session).State = EntityState.Modified;
                    db.SaveChanges();
                    return RedirectToAction("index");

                }
            }
            ViewBag.SESSIONID = new SelectList(db.Sessions, "SESSIONID", "DAY", currentbooking.SESSIONID);
            return View(currentbooking);
        }
 public ActionResult DeleteConfirmed(int id)
 {
     Booking booking = db.Bookings.Find(id);
     Session session =new Session();
     foreach (Session s in db.Sessions)
     {
         if(s.SESSIONID==(int)booking.SESSIONID)
         {
             session = s;
             break;
         }
     }
     db.Bookings.Remove(booking);
     session.SEAT = session.SEAT + booking.BOOKEDSEATS;
     db.Entry(session).State = EntityState.Modified;
     db.SaveChanges();
     return RedirectToAction("Index");
 }