public IActionResult Seed() { var seedGenres = new List <GenreModel>() { new GenreModel { GenreName = "Action", }, new GenreModel { GenreName = "Horror", }, new GenreModel { GenreName = "Fantasy", }, }; var seedMovies = new List <MovieModel>() { new MovieModel { MovieName = "Speed", MovieDescription = "Need for speed", GenreID = 1 }, new MovieModel { MovieName = "IT", MovieDescription = "Scary clowns", GenreID = 2 }, new MovieModel { MovieName = "The Hobbit", MovieDescription = "Small people save the world", GenreID = 3 }, }; var seedCustomers = new List <CustomerModel>() { new CustomerModel { CustomerName = "Jon Snow", CustomerPhoneNumber = "555-999-1234", }, new CustomerModel { CustomerName = "Cersei Lanister", CustomerPhoneNumber = "222-444-6666", }, new CustomerModel { CustomerName = "Tyrion Lanister", CustomerPhoneNumber = "888-111-3333", }, }; seedGenres.ForEach(genre => _context.Genre.Add(genre)); seedMovies.ForEach(movie => _context.Movie.Add(movie)); seedCustomers.ForEach(customer => _context.Customer.Add(customer)); _context.SaveChanges(); return(Ok()); }
public IActionResult CreateRecord(int movie, int customer, DateTime rentaldate, DateTime duedate) { var newRecord = new RentalRecordModel { MovieID = movie, CustomerID = customer, RentalDate = rentaldate, DueDate = duedate }; _context.RentalRecord.Add(newRecord); _context.SaveChanges(); return(Redirect("Index")); }