public ActionResult DeleteConfirmed(int id)
        {
            shows shows = db.shows.Find(id);

            db.shows.Remove(shows);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
 public ActionResult Edit([Bind(Include = "show_id,show_title,num_seasons,initial_year")] shows shows)
 {
     if (ModelState.IsValid)
     {
         db.Entry(shows).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(shows));
 }
Esempio n. 3
0
        public IHttpActionResult GetShows(long id)
        {
            shows show = db.shows.Find(id);

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

            return(Ok(show));
        }
        public ActionResult Create([Bind(Include = "show_id,show_title,num_seasons,initial_year")] shows shows)
        {
            if (ModelState.IsValid)
            {
                db.shows.Add(shows);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(shows));
        }
Esempio n. 5
0
 private void lv_Click(object sender, EventArgs e)
 {
     if ((selectB == null) || (selectB == " ") || (selectB == "-") || (selectB).Length < 1)
     {
         MessageBox.Show("This hour is free");
     }
     else
     {
         shows s = new shows(selectB, d, idd, hr);
         s.ShowDialog();
     }
 }
        // GET: shows/Delete/5
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            shows shows = db.shows.Find(id);

            if (shows == null)
            {
                return(HttpNotFound());
            }
            return(View(shows));
        }
Esempio n. 7
0
        public IHttpActionResult booking()
        {
            string token   = formData("token");
            string email   = formData("email");
            long   show_id = long.Parse(formData("show_id"));
            int    seats   = int.Parse(formData("seats"));

            users user;

            if (token == null)
            {
                user = UserController.userByEmail(db, email);

                if (user == null)
                {
                    //Creat new user
                    user       = new users();
                    user.email = email;

                    db.users.Add(user);
                    db.SaveChanges();
                }
            }
            else
            {
                user = UserController.userByToken(db, token);

                if (user == null)
                {
                    return(Content(HttpStatusCode.Forbidden, "You took a wrong turn somewere"));
                }
            }

            shows show = db.shows.Find(show_id);

            if (show == null)
            {
                return(Content(HttpStatusCode.BadRequest, "Show not fund"));
            }

            if (DateTime.Compare(show.start_at, DateTime.Now) < 0)
            {
                return(Content(HttpStatusCode.Gone, "Show alredy started"));
            }

            auditoriums auditorium = db.auditoriums.Find(show.auditorium_id);

            IQueryable <reservations> querry = db.reservations.Where(reservations => reservations.show_id == show_id);
            int seatsTaken     = querry.Sum(reservations => reservations.seat_count);
            int seatsRemaining = auditorium.seats_total - seatsTaken;

            if (seats > seatsRemaining)
            {
                return(Content(HttpStatusCode.Conflict, "Not enough seats available"));
            }

            reservations reservation = new reservations();

            reservation.user_id           = user.id;
            reservation.show_id           = show_id;
            reservation.seat_count        = seats;
            reservation.first_seat_number = seatsTaken + 1;
            reservation.reserved_at       = DateTime.Now;

            db.reservations.Add(reservation);
            db.SaveChanges();

            return(Ok(reservation));
        }