public DetailsModel(RazorPagesMovie.Models.RazorPagesMovieContext context) { _context = context; }
public static void Initialize(IServiceProvider serviceProvider) { using (var context = new RazorPagesMovieContext( serviceProvider.GetRequiredService < DbContextOptions <RazorPagesMovieContext> >())) { //look for any movies. if (context.Movie.Any()) { return; //DB has been seeded } context.Movie.AddRange( new Movie { Title = "Spider Man ", ReleaseDate = DateTime.Parse("2015-3-11"), Genre = "Superhero", Price = 88M, Rating = "G" }, new Movie { Title = "Inception ", ReleaseDate = DateTime.Parse("2018-1-11"), Genre = "Sci-Fic", Price = 99M, Rating = "PG-13" }, new Movie { Title = "The Wadering Earth ", ReleaseDate = DateTime.Parse("01/13/2019"), Genre = "Sci-Fic", Price = 110M, Rating = "G" }, new Movie { Title = "Iron Man", ReleaseDate = DateTime.Parse("12/12/2015"), Genre = "Superhero", Price = 30M, Rating = "G" }, new Movie { Title = "DealPool", ReleaseDate = DateTime.Parse("1/4/2017"), Genre = "Superhero", Price = 55M, Rating = "R" } ); context.SaveChanges(); } }
public CreateModel(RazorPagesMovie.Models.RazorPagesMovieContext context) { _context = context; }
public IndexModel(RazorPagesMovie.Models.RazorPagesMovieContext context) { // sets _context to the database context (the data?) _context = context; }
public EditModel(RazorPagesMovie.Models.RazorPagesMovieContext context) { _context = context; }
public GalleryModel(RazorPagesMovie.Models.RazorPagesMovieContext context) { _context = context; }
public static void Initialize(IServiceProvider serviceProvider) { using (var context = new RazorPagesMovieContext( serviceProvider.GetRequiredService < DbContextOptions <RazorPagesMovieContext> >())) { // Look for any movies. if (context.Movie.Any()) { return; // DB has been seeded } context.Movie.AddRange( new Movie { Title = "When Harry Met Sally", ReleaseDate = DateTime.Parse("1989-2-12"), Genre = "Romantic Comedy", Price = 7.99M, Rating = "R" }, new Movie { Title = "Ghostbusters ", ReleaseDate = DateTime.Parse("1984-3-13"), Genre = "Comedy", Price = 8.99M, Rating = "PG" }, new Movie { Title = "Ghostbusters 2", ReleaseDate = DateTime.Parse("1986-2-23"), Genre = "Comedy", Price = 9.99M, Rating = "PG" }, new Movie { Title = "Rio Bravo", ReleaseDate = DateTime.Parse("1959-4-15"), Genre = "Western", Price = 3.99M, Rating = "NA" } ); if (context.Actor.Any()) { return; // DB has been seeded } context.Actor.AddRange( new Actor { ActorId = "BM459632", LastName = "Murray", FirstName = "Bill", BirthDate = DateTime.Parse("1950-9-21") }, new Actor { ActorId = "DA632894", LastName = "Aykroyd", FirstName = "Dan", BirthDate = DateTime.Parse("1952-7-01") }, new Actor { ActorId = "BC821145", LastName = "Crystal", FirstName = "Billy", BirthDate = DateTime.Parse("1948-3-14") }, new Actor { ActorId = "JW358564", LastName = "Wayne", FirstName = "John", BirthDate = DateTime.Parse("1907-5-26") } ); context.SaveChanges(); } }
public static void Initialize(IServiceProvider serviceProvider) { using (var context = new RazorPagesMovieContext( serviceProvider.GetRequiredService <DbContextOptions <RazorPagesMovieContext> >())) { // Look for any movies. if (context.ReportList.Any()) { return; // DB has been seeded } #region snippet1 context.ReportList.AddRange( new ShowReport { Title = "When Harry Met Sally", ReleaseDate = DateTime.Parse("1989-2-12"), Type = "Romantic Comedy", Price = 7.99M, Rating = "R" }, #endregion new ShowReport { Title = "Ghostbusters ", ReleaseDate = DateTime.Parse("1984-3-13"), Type = "Comedy", Price = 8.99M, Rating = "G" }, new ShowReport { Title = "Ghostbusters 2", ReleaseDate = DateTime.Parse("1986-2-23"), Type = "Comedy", Price = 9.99M, Rating = "G" }, new ShowReport { Title = "Rio Bravo", ReleaseDate = DateTime.Parse("1959-4-15"), Type = "Western", Price = 3.99M, Rating = "NA" } ); context.SaveChanges(); } }
public static void Initialize(IServiceProvider serviceProvider) { using (var context = new RazorPagesMovieContext( serviceProvider.GetRequiredService < DbContextOptions <RazorPagesMovieContext> >())) { // Look for any movies. if (context.Movie.Any()) { return; // DB has been seeded } context.Movie.AddRange( new Movie { Title = "When Harry Met Sally", ReleaseDate = DateTime.Parse("1989-2-12"), Genre = "Romantic Comedy", Price = 7.99M, Rating = "R" }, new Movie { Title = "Ghostbusters ", ReleaseDate = DateTime.Parse("1984-3-13"), Genre = "Comedy", Price = 8.99M, Rating = "G" }, new Movie { Title = "Ghostbusters 2", ReleaseDate = DateTime.Parse("1986-2-23"), Genre = "Comedy", Price = 9.99M, Rating = "G" }, new Movie { Title = "Rio Bravo", ReleaseDate = DateTime.Parse("1959-4-15"), Genre = "Western", Price = 3.99M, Rating = "NA" }, new Movie { Title = "The Good, the bad, and the ugly", ReleaseDate = DateTime.Parse("12/1/2018"), Genre = "Western", Price = 1.19M, Rating = "PG-13" } ); context.SaveChanges(); } }
public ReviewModel(RazorPagesMovie.Models.RazorPagesMovieContext context) { _context = context; }
public static void Initialize(IServiceProvider serviceProvider) { using (var context = new RazorPagesMovieContext( serviceProvider.GetRequiredService < DbContextOptions <RazorPagesMovieContext> >())) { // Look for any movies. if (context.Movie.Any()) { return; // DB has been seeded } context.Movie.AddRange( new Movie { Title = "When Harry Met Sally", ReleaseDate = DateTime.Parse("1989-2-12"), Genre = "Romantic Comedy", Price = 7.99M, Rating = "R" }, new Movie { Title = "Ghostbusters", ReleaseDate = DateTime.Parse("1984-3-13"), Genre = "Comedy", Price = 8.99M, Rating = "G" }, new Movie { Title = "Ghostbusters 2", ReleaseDate = DateTime.Parse("1986-2-23"), Genre = "Comedy", Price = 9.99M, Rating = "G" }, new Movie { Title = "Rio Bravo", ReleaseDate = DateTime.Parse("1959-4-15"), Genre = "Western", Price = 3.99M, Rating = "NA" } ); Review Score1 = new Review { Score = 1 }; context.Add(Score1); Review Score2 = new Review { Score = 2 }; context.Add(Score2); Review Score3 = new Review { Score = 3 }; context.Add(Score3); Review Score4 = new Review { Score = 4 }; context.Add(Score4); Review Score5 = new Review { Score = 5 }; context.Add(Score5); Movie addReviewHarrySally = context.Movie.Where(m => m.Title == "When Harry Met Sally").First(); addReviewHarrySally.Reviews.Add(Score4); Movie addReviewGhost = context.Movie.Where(m => m.Title == "Ghostbusters").First(); addReviewGhost.Reviews.Add(Score3); addReviewGhost.Reviews.Add(Score2); Movie addReviewRio = context.Movie.Where(m => m.Title == "Rio Bravo").First(); addReviewRio.Reviews.Add(Score5); addReviewRio.Reviews.Add(Score5); addReviewRio.Reviews.Add(Score4); context.SaveChanges(); } }
public static void Initialize(IServiceProvider serviceProvider) { using (var context = new RazorPagesMovieContext( serviceProvider.GetRequiredService <DbContextOptions <RazorPagesMovieContext> >())) { // Look for any movies. if (context.Movie.Any()) { return; // DB has been seeded } context.Movie.AddRange( new Movie { Title = "When Harry Met Sally", ReleaseDate = DateTime.Parse("1989-2-12"), Genre = "Romantic Comedy", Price = 7.99M, Rating = "R", BoxOfficeSales = 92800000M, MyRating = 9, Distribution = "US" }, new Movie { Title = "Ghostbusters ", ReleaseDate = DateTime.Parse("1984-3-13"), Genre = "Comedy", Price = 8.99M, Rating = "PG", BoxOfficeSales = 229100000M, MyRating = 7, Distribution = "US" }, new Movie { Title = "Ghostbusters 2", ReleaseDate = DateTime.Parse("1986-2-23"), Genre = "Comedy", Price = 9.99M, Rating = "PG", BoxOfficeSales = 215400000M, MyRating = 6, Distribution = "US" }, new Movie { Title = "Rio Bravo", ReleaseDate = DateTime.Parse("1959-4-15"), Genre = "Western", Price = 3.99M, Rating = "PG13", BoxOfficeSales = 5750000M, MyRating = 10, Distribution = "US" } ); context.SaveChanges(); } }
public static void Initialize(IServiceProvider serviceProvider) { using (var context = new RazorPagesMovieContext( serviceProvider.GetRequiredService < DbContextOptions <RazorPagesMovieContext> >())) { // Look for any movies. // Look for any students. if (context.Students.Any()) { return; // DB has been seeded } var students = new Student[] { new Student { FirstMidName = "Carson", LastName = "Alexander", EnrollmentDate = DateTime.Parse("2019-09-01") }, new Student { FirstMidName = "Meredith", LastName = "Alonso", EnrollmentDate = DateTime.Parse("2017-09-01") }, new Student { FirstMidName = "Arturo", LastName = "Anand", EnrollmentDate = DateTime.Parse("2018-09-01") }, new Student { FirstMidName = "Gytis", LastName = "Barzdukas", EnrollmentDate = DateTime.Parse("2017-09-01") }, new Student { FirstMidName = "Yan", LastName = "Li", EnrollmentDate = DateTime.Parse("2017-09-01") }, new Student { FirstMidName = "Peggy", LastName = "Justice", EnrollmentDate = DateTime.Parse("2016-09-01") }, new Student { FirstMidName = "Laura", LastName = "Norman", EnrollmentDate = DateTime.Parse("2018-09-01") }, new Student { FirstMidName = "Nino", LastName = "Olivetto", EnrollmentDate = DateTime.Parse("2019-09-01") } }; foreach (Student s in students) { context.Students.Add(s); } context.SaveChanges(); var courses = new Course[] { new Course { CourseID = 1050, Title = "Chemistry", Credits = 3 }, new Course { CourseID = 4022, Title = "Microeconomics", Credits = 3 }, new Course { CourseID = 4041, Title = "Macroeconomics", Credits = 3 }, new Course { CourseID = 1045, Title = "Calculus", Credits = 4 }, new Course { CourseID = 3141, Title = "Trigonometry", Credits = 4 }, new Course { CourseID = 2021, Title = "Composition", Credits = 3 }, new Course { CourseID = 2042, Title = "Literature", Credits = 4 } }; foreach (Course c in courses) { context.Courses.Add(c); } context.SaveChanges(); var enrollments = new Enrollment[] { new Enrollment { StudentID = 1, CourseID = 1050, Grade = Grade.A }, new Enrollment { StudentID = 1, CourseID = 4022, Grade = Grade.C }, new Enrollment { StudentID = 1, CourseID = 4041, Grade = Grade.B }, new Enrollment { StudentID = 2, CourseID = 1045, Grade = Grade.B }, new Enrollment { StudentID = 2, CourseID = 3141, Grade = Grade.F }, new Enrollment { StudentID = 2, CourseID = 2021, Grade = Grade.F }, new Enrollment { StudentID = 3, CourseID = 1050 }, new Enrollment { StudentID = 4, CourseID = 1050 }, new Enrollment { StudentID = 4, CourseID = 4022, Grade = Grade.F }, new Enrollment { StudentID = 5, CourseID = 4041, Grade = Grade.C }, new Enrollment { StudentID = 6, CourseID = 1045 }, new Enrollment { StudentID = 7, CourseID = 3141, Grade = Grade.A }, }; foreach (Enrollment e in enrollments) { context.Enrollments.Add(e); } context.SaveChanges(); if (context.Movie.Any()) { return; // DB has been seeded } for (var i = 0; i < 5; i++) { context.Movie.AddRange( new Movie { Title = "When Harry Met Sally", ReleaseDate = DateTime.Parse("1989-2-12"), Genre = "Romantic Comedy", Price = 7.99M, Rating = "R" }, new Movie { Title = "Ghostbusters ", ReleaseDate = DateTime.Parse("1984-3-13"), Genre = "Comedy", Price = 8.99M, Rating = "R" }, new Movie { Title = "Ghostbusters 2", ReleaseDate = DateTime.Parse("1986-2-23"), Genre = "Comedy", Price = 9.99M, Rating = "R" }, new Movie { Title = "Rio Bravo", ReleaseDate = DateTime.Parse("1959-4-15"), Genre = "Western", Price = 3.99M, Rating = "R" } ); } context.SaveChanges(); } }
public static void Initialize(IServiceProvider serviceProvider) { using (var context = new RazorPagesMovieContext( serviceProvider.GetRequiredService <DbContextOptions <RazorPagesMovieContext> >())) { //Look for any movie if (context.Movie.Any()) { return; } context.Movie.AddRange( new Movie { Title = "When Harry Met Sally", ReleaseDate = DateTime.Parse("1989-2-12"), Genre = "Romantic Comedy", Price = 7.99M, Rating = "A" }, new Movie { Title = "Ghostbusters ", ReleaseDate = DateTime.Parse("1984-3-13"), Genre = "Comedy", Price = 8.99M, Rating = "B" }, new Movie { Title = "Ghostbusters 2", ReleaseDate = DateTime.Parse("1986-2-23"), Genre = "Comedy", Price = 9.99M, Rating = "A" }, new Movie { Title = "Rio Bravo", ReleaseDate = DateTime.Parse("1959-4-15"), Genre = "Western", Price = 3.99M, Rating = "C" }, new Movie { Title = "London's Query", ReleaseDate = DateTime.Parse("1999-4-15"), Genre = "Tragedy", Price = 4.00M, Rating = "A" }, new Movie { Title = "Dance of the Leaf", ReleaseDate = DateTime.Parse("2012-12-01"), Genre = "Thriller", Price = 1.99M, Rating = "F" }, new Movie { Title = "Jonhney Bravo", ReleaseDate = DateTime.Parse("1959-4-15"), Genre = "Comedy", Price = 1.90M, Rating = "B" } ); context.SaveChanges(); } }
public IndexModel(RazorPagesMovie.Models.RazorPagesMovieContext context) { _context = context; }
public static void Initialize(IServiceProvider serviceProvider) { bool mustSaveChanges = false; using RazorPagesMovieContext context = new RazorPagesMovieContext( serviceProvider.GetRequiredService < DbContextOptions <RazorPagesMovieContext> >()); if (context.Movie.Count(_ => _.Title.Equals("When Harry Met Sally")) == 0) { context.Movie.Add(new Movie { Title = "When Harry Met Sally", ReleaseDate = DateTime.Parse("1989-2-12"), Genre = "Romantic Comedy", Price = 7.99M, Rating = "R" }); mustSaveChanges = true; } if (context.Movie.Count(_ => _.Title.Equals("Ghostbusters")) == 0) { context.Movie.Add(new Movie { Title = "Ghostbusters", ReleaseDate = DateTime.Parse("1984-3-13"), Genre = "Comedy", Price = 8.99M, Rating = "G" }); mustSaveChanges = true; } if (context.Movie.Count(_ => _.Title.Equals("Ghostbusters 2")) == 0) { context.Movie.Add(new Movie { Title = "Ghostbusters 2", ReleaseDate = DateTime.Parse("1986-2-23"), Genre = "Comedy", Price = 9.99M, Rating = "G" }); mustSaveChanges = true; } if (context.Movie.Count(_ => _.Title.Equals("Rio Bravo")) == 0) { context.Movie.Add(new Movie { Title = "Rio Bravo", ReleaseDate = DateTime.Parse("1959-4-15"), Genre = "Western", Price = 3.99M, Rating = "NA" }); mustSaveChanges = true; } if (mustSaveChanges) { context.SaveChanges(); } List <Movie> notRatedMovies = context.Movie.Where(_ => string.IsNullOrEmpty(_.Rating)).ToList(); if (notRatedMovies.Count > 0) { notRatedMovies.ForEach(_ => _.Rating = "NA"); context.SaveChanges(); } }
public static void Initialize(IServiceProvider serviceProvider) { using (var context = new RazorPagesMovieContext( serviceProvider.GetRequiredService < DbContextOptions <RazorPagesMovieContext> >())) { // Look for any movies. if (context.Movie.Any()) { return; // DB has been seeded } context.Movie.AddRange( new Movie { Title = "When Harry Met Sally", ReleaseDate = DateTime.Parse("1989-2-12"), Genre = "Romantic Comedy", Price = 7.99M, Rating = "R", Reviews = new List <Review> { new Review { Score = 5 }, new Review { Score = 4 }, } }, new Movie { Title = "Ghostbusters ", ReleaseDate = DateTime.Parse("1984-3-13"), Genre = "Comedy", Price = 8.99M, Rating = "PG-13", Reviews = new List <Review> { new Review { Score = 3 }, new Review { Score = 4 }, new Review { Score = 1 } } }, new Movie { Title = "Ghostbusters 2", ReleaseDate = DateTime.Parse("1986-2-23"), Genre = "Comedy", Price = 9.99M, Rating = "PG-13", Reviews = new List <Review> { new Review { Score = 5 }, } }, new Movie { Title = "Rio Bravo", ReleaseDate = DateTime.Parse("1959-4-15"), Genre = "Western", Price = 3.99M, Rating = "R" } ); } }
public static void Initialize(IServiceProvider serviceProvider) { using (var context = new RazorPagesMovieContext( serviceProvider.GetRequiredService <DbContextOptions <RazorPagesMovieContext> >())) { // Look for any movies. if (context.Movie.Any() && context.Customer.Any()) { return; // DB has been seeded } context.Movie.AddRange( new Movie { Title = "When Harry Met Sally", ReleaseDate = DateTime.Parse("1989-2-12"), Genre = "Romantic Comedy", Price = 7.99M, Rating = "R", Director = "Unknown" }, new Movie { Title = "Ghostbusters ", ReleaseDate = DateTime.Parse("1984-3-13"), Genre = "Comedy", Price = 8.99M, Rating = "R", Director = "Ivan Reitman" }, new Movie { Title = "Ghostbusters 2", ReleaseDate = DateTime.Parse("1986-2-23"), Genre = "Comedy", Price = 9.99M, Rating = "R", Director = "Unknown" }, new Movie { Title = "Rio Bravo", ReleaseDate = DateTime.Parse("1959-4-15"), Genre = "Western", Price = 3.99M, Rating = "R", Director = "Unknown" } ); context.Customer.AddRange( new Customer { EmailAddress = "*****@*****.**", Salutation = Title.Mr, Name = "Arnoldo", Lastname = "Perozo", BirthDate = DateTime.Parse("1977-3-05"), Gender = 0, Address = "Heredia", Phone = "123-4567890" }, new Customer { EmailAddress = "*****@*****.**", Salutation = Title.Mrs, Name = "Rita", Lastname = "Moreno", BirthDate = DateTime.Parse("1989-10-10"), Gender = Gender.Female, Address = "Not Sure", Phone = "123-4567890" }, new Customer { EmailAddress = "*****@*****.**", Salutation = Title.Miss, Name = "Johanna", Lastname = "Sanchez", BirthDate = DateTime.Parse("1995-8-18"), Gender = Gender.Female, Address = "Don't Know", Phone = "123-4567890" }); context.SaveChanges(); } }