public async Task <IActionResult> PutMovieRentals(int id, MovieRentals movieRentals) { if (id != movieRentals.MovieID) { return(BadRequest()); } _context.Entry(movieRentals).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!MovieRentalsExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <ActionResult <MovieRentals> > PostMovieRentals(MovieRentals movieRentals) { _context.MovieRentals.Add(movieRentals); await _context.SaveChangesAsync(); return(CreatedAtAction("GetMovieRentals", new { id = movieRentals.MovieID }, movieRentals)); }
public IHttpActionResult CreateNewRental(MovieRentalsDto newRental) { var customer = _db.Customers.Single(c => c.CustomerID == newRental.CustomerID); var moviesList = _db.Movies.Where(c => newRental.MovieIDs.Contains(c.MovieID)).ToList(); Console.WriteLine(moviesList); foreach (var movie in moviesList) { if (movie.NumberAvailable == 0) { return(BadRequest()); } movie.NumberAvailable--; var rental = new MovieRentals { Customer = customer, Movie = movie, DateRented = DateTime.Now }; _db.MovieRentals.Add(rental); } _db.SaveChanges(); return(Ok("Done")); }
// GET: Movies public ActionResult Random() { MovieRentals model = new MovieRentals(); model.movie = m; model.customers = lista; return(View(model)); }
//localhost:port/Movies/Random public ActionResult Random() { MovieRentals model = new MovieRentals(); model.movie = movie; model.clients = clients; return(View(model)); }
public ActionResult ShowMovie(int id) { var movie = moviesList.ElementAt(id); MovieRentals model = new MovieRentals(); model.movie = movie; model.customers = lista; return View(model); }
public ActionResult ShowMovie(int id) { var movie = _context.Movies.FirstOrDefault(z => z.id == id); MovieRentals model = new MovieRentals(); model.movie = movie; model.customers = movie.clients.ToList(); return(View(model)); }
public void Setup() { dateTime = Substitute.For <IDateTime>(); sut = new MovieRentals(dateTime); testCustomer = new Customer { Name = "Tess", SocialSecurityNumber = "123" }; testVideo = new Movie { Title = "Titanic" }; }
public void AddMovieRental(MovieRental movieRental) { if (MoviePurchases.Count > 0 && MoviePurchases.Exists(mp => mp.MovieId == movieRental.MovieId)) { throw new MovieAlreadyPurchasedException("Movie already purchased."); } if (MovieRentals.Count > 0 && MovieRentals.Exists(mp => mp.MovieId == movieRental.MovieId)) { throw new MovieAlreadyRentedException("Movie already rented."); } MovieRentals.Add(movieRental); }
private void MovieRentalButton_Click(object sender, EventArgs e) { MovieRentals movieRentals = new MovieRentals(); movieRentals.Show(); }