Exemplo n.º 1
0
        public ActionResult DeleteConfirmed(int id)
        {
            TheaterMovy theaterMovy = db.TheaterMovies.Find(id);

            db.TheaterMovies.Remove(theaterMovy);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Exemplo n.º 2
0
 public ActionResult Edit([Bind(Include = "TMID,TheaterID,MovieID,ShowtimeID,ReservationLimit")] TheaterMovy theaterMovy)
 {
     if (ModelState.IsValid)
     {
         db.Entry(theaterMovy).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.MovieID    = new SelectList(db.Movies, "MovieId", "Name", theaterMovy.MovieID);
     ViewBag.ShowtimeID = new SelectList(db.Showtimes, "ShowtimeID", "ShowtimeID", theaterMovy.ShowtimeID);
     ViewBag.TheaterID  = new SelectList(db.Theaters, "TheaterID", "TheaterName", theaterMovy.TheaterID);
     return(View(theaterMovy));
 }
Exemplo n.º 3
0
        // GET: TheaterMovies/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            TheaterMovy theaterMovy = db.TheaterMovies.Find(id);

            if (theaterMovy == null)
            {
                return(HttpNotFound());
            }
            return(View(theaterMovy));
        }
Exemplo n.º 4
0
        public ActionResult Create([Bind(Include = "TMID,TheaterID,MovieID,ShowtimeID,ReservationLimit")] TheaterMovy theaterMovy, int Day, int Month, int Year)
        {
            if (ModelState.IsValid)
            {
                theaterMovy.Date = new DateTime(Year, Month, Day);
                db.TheaterMovies.Add(theaterMovy);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.MovieID    = new SelectList(db.Movies, "MovieId", "Name", theaterMovy.MovieID);
            ViewBag.ShowtimeID = new SelectList(db.Showtimes, "ShowtimeID", "ShowtimeID", theaterMovy.ShowtimeID);
            ViewBag.TheaterID  = new SelectList(db.Theaters, "TheaterID", "TheaterName", theaterMovy.TheaterID);
            return(View(theaterMovy));
        }
Exemplo n.º 5
0
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            TheaterMovy theaterMovy = db.TheaterMovies.Find(id);

            if (theaterMovy == null)
            {
                return(HttpNotFound());
            }
            ViewBag.MovieID    = new SelectList(db.Movies, "MovieId", "Name", theaterMovy.MovieID);
            ViewBag.ShowtimeID = new SelectList(db.Showtimes, "ShowtimeID", "ShowtimeID", theaterMovy.ShowtimeID);
            ViewBag.TheaterID  = new SelectList(db.Theaters, "TheaterID", "TheaterName", theaterMovy.TheaterID);
            return(View(theaterMovy));
        }
Exemplo n.º 6
0
        public ActionResult MakeReservation(int?numOfTickets, int?tmid)
        {
            if (numOfTickets < 1 || numOfTickets == null || tmid == null || tmid == 0)
            {
                var theaterMovies = db.TheaterMovies.Include(x => x.Movy).Include(x => x.Showtime).Include(x => x.Theater).Include(x => x.SeatIDs);

                TheaterMovy tm = db.TheaterMovies.Where(x => x.TMID == tmid).SingleOrDefault();
                Session["error"] = "you missed something. Double check you chose a time AND how many tickets you want";
                return(RedirectToAction("GetReservation", new { theaterID = (int)Session["selectedTheater"], movieID = (int)Session["selectedMovie"] }));
            }
            string userID;

            if (Request.IsAuthenticated)
            {
                userID = User.Identity.GetUserId();
            }
            else
            {
                userID = "761aa9be-9849-4596-a8e7-d30611343cb9";
            }
            for (int i = 0; i < numOfTickets; i++)
            {
                Ticket t = new Ticket();

                t.UserID = userID;

                db.Tickets.Add(t);
            }
            db.SaveChanges();

            var purchasedTickets = db.Tickets.Where(x => x.UserID == userID).OrderBy(x => x.TicketID).Take((int)numOfTickets).ToList();

            foreach (var item in purchasedTickets)
            {
                SeatID s = new SeatID();
                s.TMID     = (int)tmid;
                s.TicketID = item.TicketID;
                db.SeatIDs.Add(s);
            }
            db.SaveChanges();

            return(View());
        }