// POST api/<controller> public void Post() { Movies movie = new Movies(); movie.name = HttpContext.Current.Request.Params["name"]; movie.date = Convert.ToDateTime(HttpContext.Current.Request.Params["date"]); movie.year = HttpContext.Current.Request.Params["year"]; movie.genre = HttpContext.Current.Request.Params["genre"]; movie.length = Convert.ToInt32(HttpContext.Current.Request.Params["length"]); movie.seats = Convert.ToInt32(HttpContext.Current.Request.Params["seats"]); HttpPostedFile file = HttpContext.Current.Request.Files["img"]; //string ext = Path.GetExtension(file.FileName); file.SaveAs(HttpContext.Current.Server.MapPath("~") + "/images/" + file.FileName); movie.movie_img_url = "/images/" + file.FileName; Theaters theater = new Theaters(); theater.hall_num = Convert.ToInt32(HttpContext.Current.Request.Params["hall_num"]); theater.avail_seats_arr = "0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"; movie.Theaters.Add(theater); CinemaDB db = new CinemaDB(); db.Movies.Add(movie); db.SaveChanges(); }
public void Put(int movieNumber, string newSeatsArr) { CinemaDB db = new CinemaDB(); Theaters theater = db.Theaters.SingleOrDefault(x => x.movie_number == movieNumber); if (theater != null) { theater.avail_seats_arr = newSeatsArr; db.SaveChanges(); } }
public void Post(int movieNum, [FromBody] int hallNum) { Theaters theater = new Theaters(); theater.movie_number = movieNum; theater.hall_num = hallNum; theater.avail_seats_arr = "0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"; CinemaDB db = new CinemaDB(); db.Theaters.Add(theater); db.SaveChanges(); }
public void Put(int movieNumber, string userAmountSeats) { CinemaDB db = new CinemaDB(); Movies movie = db.Movies.SingleOrDefault(x => x.number == movieNumber); if (movie != null) { int?oldAmount = movie.seats; movie.seats = oldAmount - Convert.ToInt32(userAmountSeats); db.SaveChanges(); } }
public void Post(int num, int seatsAmount, [FromBody] string seatsPositions) { Orders order = new Orders(); order.movie_number = num; order.user_seats_amount = seatsAmount; order.order_date = DateTime.Now; order.user_seats_positions = seatsPositions; CinemaDB db = new CinemaDB(); db.Orders.Add(order); db.SaveChanges(); }
//cancelling a booking public UserFilms CancelBooking(int filmId) { using (var db = new CinemaDB()) { var userFilm = db.UserFilms.FirstOrDefault(u => u.FilmId == filmId); if (userFilm != null) { db.UserFilms.Remove(userFilm); db.SaveChanges(); return(userFilm); } } return(null); }
public List <Reservation> AddToBasket(string title) { using (var db = new CinemaDB()) { var movie = db.MovieInfo.FirstOrDefault(m => m.Title.ToLower() == title.ToLower()); if (movie != null) { db.Reservation.Add(new Reservation() { MovieId = movie.Id, }); db.SaveChanges(); } } return(null); }
public UserBookings CancelBooking(string name) { using (var db = new CinemaDB()) { var booking = db.UserBookings.FirstOrDefault(b => b.Name.ToLower() == name.ToLower()); if (booking != null) { db.UserBookings.Remove(booking); db.SaveChanges(); return(booking); } } return(null); }
public Films BookFilm(int id, string time) { using (var db = new CinemaDB()) { var film = managerCinema.ChooseAFilm(id); if (film != null) { db.UserFilms.Add(new UserFilms() { FilmId = film.Id, FilmTitle = film.Title, ScreeningTime = time }); db.SaveChanges(); return(film); } } return(null); }
public Movies CreateBooking(string name) { using (var db = new CinemaDB()) { var movie = db.Movies.FirstOrDefault(m => m.Name.ToLower() == name.ToLower()); if (movie.AvailableTime != null) { db.UserBookings.Add(new UserBookings() { Category = movie.Category, Name = movie.Name, AvailableTime = movie.AvailableTime }); db.SaveChanges(); return(movie); } } return(null); }