diff --git a/CCMovieDatabase/CCMovieDatabase.csproj.user b/CCMovieDatabase/CCMovieDatabase.csproj.user index ec209e7..79c516b 100644 --- a/CCMovieDatabase/CCMovieDatabase.csproj.user +++ b/CCMovieDatabase/CCMovieDatabase.csproj.user @@ -14,7 +14,7 @@ False True 650 - ApiControllerEmptyScaffolder - root/Common/Api + MvcControllerWithContextScaffolder + root/Common/MVC/Controller \ No newline at end of file diff --git a/CCMovieDatabase/Controllers/ChristianListController.cs b/CCMovieDatabase/Controllers/ChristianListController.cs new file mode 100644 index 0000000..17cb51e --- /dev/null +++ b/CCMovieDatabase/Controllers/ChristianListController.cs @@ -0,0 +1,175 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Mvc; +using Microsoft.AspNetCore.Mvc.Rendering; +using Microsoft.EntityFrameworkCore; +using CCMovieDatabase.Data; +using CCMovieDatabase.Models; + +namespace CCMovieDatabase.Controllers +{ + public class ChristianListController : Controller + { + private readonly MovieContext _context; + + public ChristianListController(MovieContext context) + { + _context = context; + } + + // GET: ChristianList + public async Task Index() + { + + int[] myMovieIds = { 3, 4, 5, 6, 7 }; + + var myMovies = await _context.Movie + .Where(m => myMovieIds.Contains(m.Id)) + .ToListAsync(); + + var movieContext = _context.Movie.Include(m => m.Rating); + return View(await movieContext.ToListAsync()); + return View(myMovies); + } + + // GET: ChristianList/Details/5 + public async Task Details(int? id) + { + + int[] myMovieIds = { 3, 4, 5, 6, 7 }; + + if (id == null || !myMovieIds.Contains(id.Value)) + { + return NotFound(); + } + + var movie = await _context.Movie + .Include(m => m.Rating) + .FirstOrDefaultAsync(m => m.Id == id); + if (movie == null) + { + return NotFound(); + } + + return View(movie); + } + + // GET: ChristianList/Create + public IActionResult Create() + { + ViewData["RatingId"] = new SelectList(_context.Ratings, "RatingId", "RatingId"); + return View(); + } + + // POST: ChristianList/Create + // To protect from overposting attacks, enable the specific properties you want to bind to. + // For more details, see http://go.microsoft.com/fwlink/?LinkId=317598. + [HttpPost] + [ValidateAntiForgeryToken] + public async Task Create([Bind("Id,Title,Description,ReleaseDate,RatingId,ThumbnailURL")] Movie movie) + { + if (ModelState.IsValid) + { + _context.Add(movie); + await _context.SaveChangesAsync(); + return RedirectToAction(nameof(Index)); + } + ViewData["RatingId"] = new SelectList(_context.Ratings, "RatingId", "RatingId", movie.RatingId); + return View(movie); + } + + // GET: ChristianList/Edit/5 + public async Task Edit(int? id) + { + if (id == null) + { + return NotFound(); + } + + var movie = await _context.Movie.FindAsync(id); + if (movie == null) + { + return NotFound(); + } + ViewData["RatingId"] = new SelectList(_context.Ratings, "RatingId", "RatingId", movie.RatingId); + return View(movie); + } + + // POST: ChristianList/Edit/5 + // To protect from overposting attacks, enable the specific properties you want to bind to. + // For more details, see http://go.microsoft.com/fwlink/?LinkId=317598. + [HttpPost] + [ValidateAntiForgeryToken] + public async Task Edit(int id, [Bind("Id,Title,Description,ReleaseDate,RatingId,ThumbnailURL")] Movie movie) + { + if (id != movie.Id) + { + return NotFound(); + } + + if (ModelState.IsValid) + { + try + { + _context.Update(movie); + await _context.SaveChangesAsync(); + } + catch (DbUpdateConcurrencyException) + { + if (!MovieExists(movie.Id)) + { + return NotFound(); + } + else + { + throw; + } + } + return RedirectToAction(nameof(Index)); + } + ViewData["RatingId"] = new SelectList(_context.Ratings, "RatingId", "RatingId", movie.RatingId); + return View(movie); + } + + // GET: ChristianList/Delete/5 + public async Task Delete(int? id) + { + if (id == null) + { + return NotFound(); + } + + var movie = await _context.Movie + .Include(m => m.Rating) + .FirstOrDefaultAsync(m => m.Id == id); + if (movie == null) + { + return NotFound(); + } + + return View(movie); + } + + // POST: ChristianList/Delete/5 + [HttpPost, ActionName("Delete")] + [ValidateAntiForgeryToken] + public async Task DeleteConfirmed(int id) + { + var movie = await _context.Movie.FindAsync(id); + if (movie != null) + { + _context.Movie.Remove(movie); + } + + await _context.SaveChangesAsync(); + return RedirectToAction(nameof(Index)); + } + + private bool MovieExists(int id) + { + return _context.Movie.Any(e => e.Id == id); + } + } +} diff --git a/CCMovieDatabase/Data/MovieContext.cs b/CCMovieDatabase/Data/MovieContext.cs index 1d9cab4..7cfbbbc 100644 --- a/CCMovieDatabase/Data/MovieContext.cs +++ b/CCMovieDatabase/Data/MovieContext.cs @@ -42,6 +42,12 @@ protected override void OnModelCreating(ModelBuilder modelBuilder) { new Movie { Id = 1, Title = "Shrek", ReleaseDate = new DateOnly(2001, 04, 26), Description = "A mean lord exiles fairytale creatures to the swamp of a grumpy ogre, who must go on a quest and rescue a princess for the lord in order to get his land back.", RatingId = 1, ThumbnailURL = "https://encrypted-tbn1.gstatic.com/images?q=tbn:ANd9GcTG_q0A0cypAsXxYlgs5J_554BrcnjeeKExlQE3ZaZUuPYv0fUd" }, new Movie { Id = 2, Title = "Shrek 2", ReleaseDate = new DateOnly(2002, 04, 26), Description = "Shrek is back baby!", RatingId = 1, ThumbnailURL = "https://encrypted-tbn3.gstatic.com/images?q=tbn:ANd9GcTPx7lW6h0G1O9-npEnVPL07fT74Tp6SFl0i47nxfypyVBcQFdS" }, + new Movie { Id = 3, Title = "Austin Powers: International Man of Mystery", ReleaseDate = new DateOnly(1997, 05, 02), Description = "A world-class playboy and part-time secret agent from the 1960s emerges after thirty years in a cryogenic state to battle with his nemesis Dr. Evil.", RatingId = 1, ThumbnailURL = "https://encrypted-tbn2.gstatic.com/images?q=tbn:ANd9GcTlO5X0VeATdsHkdAiSqrIjnibxUZFxHvr56dYDONVdRyNsdJyhhAgLl7cMeUZX_nJL1szd1r0PWHMyHtWNoVVvP1FZNLZ6-A"}, + new Movie { Id = 4, Title = "Austin Powers: The Spy Who Shagged Me", ReleaseDate = new DateOnly(1999, 06, 11), Description = "Dr. Evil is back and has invented a new time machine that allows him to go back to the 1960s and steal Austin Powers' mojo, inadvertently leaving him \"shagless\".", RatingId = 1, ThumbnailURL = "https://encrypted-tbn2.gstatic.com/images?q=tbn:ANd9GcSIfeD5mGXpWtcfJ_ycbhE_9ZAqnEugZyaEOd9vnjZYPipvpQq2olg1Bl2uyE6N_VcV7L0cnGIGgg8WqQD-fRo-USv7_4lLeQ" }, + new Movie { Id = 5, Title = "Austin Powers in Goldmember", ReleaseDate = new DateOnly(2002, 07, 26), Description = "Upon learning that his father has been kidnapped, Austin Powers must travel to 1975 and defeat the aptly named villain Goldmember, who is working with Dr. Evil.", RatingId = 1, ThumbnailURL = "https://static.qobuz.com/images/covers/66/49/0081227784966_600.jpg" }, + new Movie { Id = 6, Title = "Five Nights at Freddy's", ReleaseDate = new DateOnly(2023, 10, 27), Description = "A troubled security guard begins working at Freddy Fazbear's Pizza. During his five nights on the job, he realizes that something is wrong with the pizzeria and pretty soon finds the truth about its animatronics.", RatingId = 1, ThumbnailURL = "https://encrypted-tbn1.gstatic.com/images?q=tbn:ANd9GcTaydvBSSHZ_qYRr2QlfuisPN1JxzqmasvFmmuhCn9-vLzw6D1cY7NXscySkTHC80g2ASZKzSi2ATEICdak16TVc_kxIkeXFA" }, + new Movie { Id = 7, Title = "Five Nights ar Freddy's 2", ReleaseDate = new DateOnly(2025, 12, 05), Description = "Anyone can survive five nights. This time, there will be no second chances.", RatingId = 1, ThumbnailURL = "https://encrypted-tbn3.gstatic.com/images?q=tbn:ANd9GcQlGcWZganGfskXyYsVD1UMZmtaXp2y7nlxqJlWXAkAMSRYG6QgGZ-OCUAt77g7EC5Md-gD-7Ht8mV2OKFLj-nPQjUPW5a9DA" + } }; modelBuilder.Entity().HasData(movies); diff --git a/CCMovieDatabase/Migrations/20251206034948_MovieSeedData.Designer.cs b/CCMovieDatabase/Migrations/20251206034948_MovieSeedData.Designer.cs new file mode 100644 index 0000000..da15c00 --- /dev/null +++ b/CCMovieDatabase/Migrations/20251206034948_MovieSeedData.Designer.cs @@ -0,0 +1,537 @@ +// +using System; +using CCMovieDatabase.Data; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; + +#nullable disable + +namespace CCMovieDatabase.Migrations +{ + [DbContext(typeof(MovieContext))] + [Migration("20251206034948_MovieSeedData")] + partial class MovieSeedData + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "9.0.0") + .HasAnnotation("Relational:MaxIdentifierLength", 128); + + SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); + + modelBuilder.Entity("CCMovieDatabase.Models.ActingCredit", b => + { + b.Property("ActingCreditId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("ActingCreditId")); + + b.Property("CharacterId") + .HasColumnType("int"); + + b.Property("PersonId") + .HasColumnType("int"); + + b.HasKey("ActingCreditId"); + + b.HasIndex("CharacterId"); + + b.HasIndex("PersonId"); + + b.ToTable("ActingCredits"); + }); + + modelBuilder.Entity("CCMovieDatabase.Models.Article", b => + { + b.Property("ArticleId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("ArticleId")); + + b.Property("Author") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Body") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("CreatedAt") + .HasColumnType("datetime2"); + + b.Property("IsFeatured") + .HasColumnType("bit"); + + b.Property("ModifiedAt") + .HasColumnType("datetime2"); + + b.Property("ShortDescription") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Slug") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("ThumbnailUrl") + .HasColumnType("nvarchar(max)"); + + b.Property("Title") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("ArticleId"); + + b.ToTable("Articles"); + + b.HasData( + new + { + ArticleId = 1, + Author = "Jesse", + Body = "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.", + CreatedAt = new DateTime(2025, 11, 12, 0, 0, 0, 0, DateTimeKind.Unspecified), + IsFeatured = true, + ModifiedAt = new DateTime(2025, 11, 12, 0, 0, 0, 0, DateTimeKind.Unspecified), + ShortDescription = "Lorem Ipsum and stuff", + Slug = "hello_world", + ThumbnailUrl = "https://craftypixels.com/placeholder-image/300", + Title = "Welcome to CCMovieDatabase" + }, + new + { + ArticleId = 2, + Author = "Jesse", + Body = "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.", + CreatedAt = new DateTime(2025, 11, 12, 0, 0, 0, 0, DateTimeKind.Unspecified), + IsFeatured = true, + ModifiedAt = new DateTime(2025, 11, 12, 0, 0, 0, 0, DateTimeKind.Unspecified), + ShortDescription = "Lorem Ipsum and stuff", + Slug = "hello_world2", + ThumbnailUrl = "https://craftypixels.com/placeholder-image/300", + Title = "More Movies Added" + }, + new + { + ArticleId = 3, + Author = "Jesse", + Body = "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.", + CreatedAt = new DateTime(2025, 11, 12, 0, 0, 0, 0, DateTimeKind.Unspecified), + IsFeatured = true, + ModifiedAt = new DateTime(2025, 11, 12, 0, 0, 0, 0, DateTimeKind.Unspecified), + ShortDescription = "Lorem Ipsum and stuff", + Slug = "hello_world3", + ThumbnailUrl = "https://craftypixels.com/placeholder-image/300", + Title = "For the love of movies" + }, + new + { + ArticleId = 4, + Author = "Jesse", + Body = "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.", + CreatedAt = new DateTime(2025, 11, 12, 0, 0, 0, 0, DateTimeKind.Unspecified), + IsFeatured = true, + ModifiedAt = new DateTime(2025, 11, 12, 0, 0, 0, 0, DateTimeKind.Unspecified), + ShortDescription = "Lorem Ipsum and stuff", + Slug = "hello_world4", + ThumbnailUrl = "https://craftypixels.com/placeholder-image/300", + Title = "I wrote this" + }); + }); + + modelBuilder.Entity("CCMovieDatabase.Models.Category", b => + { + b.Property("CategoryId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("CategoryId")); + + b.Property("Name") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("CategoryId"); + + b.ToTable("Categories"); + + b.HasData( + new + { + CategoryId = 1, + Name = "Computer Accessories" + }, + new + { + CategoryId = 2, + Name = "Graphics Cards" + }, + new + { + CategoryId = 3, + Name = "Monitors" + }, + new + { + CategoryId = 4, + Name = "Hard Drives" + }); + }); + + modelBuilder.Entity("CCMovieDatabase.Models.Character", b => + { + b.Property("CharacterId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("CharacterId")); + + b.Property("Description") + .HasColumnType("nvarchar(max)"); + + b.Property("MovieId") + .HasColumnType("int"); + + b.Property("Name") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("CharacterId"); + + b.HasIndex("MovieId"); + + b.ToTable("Characters"); + }); + + modelBuilder.Entity("CCMovieDatabase.Models.CrewCredit", b => + { + b.Property("CrewCreditId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("CrewCreditId")); + + b.Property("Description") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("MovieId") + .HasColumnType("int"); + + b.Property("PersonId") + .HasColumnType("int"); + + b.HasKey("CrewCreditId"); + + b.HasIndex("MovieId"); + + b.HasIndex("PersonId"); + + b.ToTable("CrewCredits"); + }); + + modelBuilder.Entity("CCMovieDatabase.Models.Movie", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Description") + .HasColumnType("nvarchar(max)"); + + b.Property("RatingId") + .HasColumnType("int"); + + b.Property("ReleaseDate") + .HasColumnType("date"); + + b.Property("ThumbnailURL") + .HasColumnType("nvarchar(max)"); + + b.Property("Title") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.HasIndex("RatingId"); + + b.ToTable("Movie"); + + b.HasData( + new + { + Id = 1, + Description = "A mean lord exiles fairytale creatures to the swamp of a grumpy ogre, who must go on a quest and rescue a princess for the lord in order to get his land back.", + RatingId = 1, + ReleaseDate = new DateOnly(2001, 4, 26), + ThumbnailURL = "https://encrypted-tbn1.gstatic.com/images?q=tbn:ANd9GcTG_q0A0cypAsXxYlgs5J_554BrcnjeeKExlQE3ZaZUuPYv0fUd", + Title = "Shrek" + }, + new + { + Id = 2, + Description = "Shrek is back baby!", + RatingId = 1, + ReleaseDate = new DateOnly(2002, 4, 26), + ThumbnailURL = "https://encrypted-tbn3.gstatic.com/images?q=tbn:ANd9GcTPx7lW6h0G1O9-npEnVPL07fT74Tp6SFl0i47nxfypyVBcQFdS", + Title = "Shrek 2" + }, + new + { + Id = 3, + Description = "A world-class playboy and part-time secret agent from the 1960s emerges after thirty years in a cryogenic state to battle with his nemesis Dr. Evil.", + RatingId = 1, + ReleaseDate = new DateOnly(1997, 5, 2), + ThumbnailURL = "https://encrypted-tbn2.gstatic.com/images?q=tbn:ANd9GcTlO5X0VeATdsHkdAiSqrIjnibxUZFxHvr56dYDONVdRyNsdJyhhAgLl7cMeUZX_nJL1szd1r0PWHMyHtWNoVVvP1FZNLZ6-A", + Title = "Austin Powers: International Man of Mystery" + }, + new + { + Id = 4, + Description = "Dr. Evil is back and has invented a new time machine that allows him to go back to the 1960s and steal Austin Powers' mojo, inadvertently leaving him \"shagless\".", + RatingId = 1, + ReleaseDate = new DateOnly(1999, 6, 11), + ThumbnailURL = "https://encrypted-tbn2.gstatic.com/images?q=tbn:ANd9GcSIfeD5mGXpWtcfJ_ycbhE_9ZAqnEugZyaEOd9vnjZYPipvpQq2olg1Bl2uyE6N_VcV7L0cnGIGgg8WqQD-fRo-USv7_4lLeQ", + Title = "Austin Powers: The Spy Who Shagged Me" + }, + new + { + Id = 5, + Description = "Upon learning that his father has been kidnapped, Austin Powers must travel to 1975 and defeat the aptly named villain Goldmember, who is working with Dr. Evil.", + RatingId = 1, + ReleaseDate = new DateOnly(2002, 7, 26), + ThumbnailURL = "https://static.qobuz.com/images/covers/66/49/0081227784966_600.jpg", + Title = "Austin Powers in Goldmember" + }, + new + { + Id = 6, + Description = "A troubled security guard begins working at Freddy Fazbear's Pizza. During his five nights on the job, he realizes that something is wrong with the pizzeria and pretty soon finds the truth about its animatronics.", + RatingId = 1, + ReleaseDate = new DateOnly(2023, 10, 27), + ThumbnailURL = "https://encrypted-tbn1.gstatic.com/images?q=tbn:ANd9GcTaydvBSSHZ_qYRr2QlfuisPN1JxzqmasvFmmuhCn9-vLzw6D1cY7NXscySkTHC80g2ASZKzSi2ATEICdak16TVc_kxIkeXFA", + Title = "Five Nights at Freddy's" + }, + new + { + Id = 7, + Description = "Anyone can survive five nights. This time, there will be no second chances.", + RatingId = 1, + ReleaseDate = new DateOnly(2025, 12, 5), + ThumbnailURL = "https://encrypted-tbn3.gstatic.com/images?q=tbn:ANd9GcQlGcWZganGfskXyYsVD1UMZmtaXp2y7nlxqJlWXAkAMSRYG6QgGZ-OCUAt77g7EC5Md-gD-7Ht8mV2OKFLj-nPQjUPW5a9DA", + Title = "Five Nights ar Freddy's 2" + }); + }); + + modelBuilder.Entity("CCMovieDatabase.Models.Person", b => + { + b.Property("PersonId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("PersonId")); + + b.Property("FirstName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("LastName") + .HasColumnType("nvarchar(max)"); + + b.HasKey("PersonId"); + + b.ToTable("Persons"); + }); + + modelBuilder.Entity("CCMovieDatabase.Models.Product", b => + { + b.Property("ProductId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("ProductId")); + + b.Property("CategoryId") + .HasColumnType("int"); + + b.Property("Description") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Name") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("ProductId"); + + b.HasIndex("CategoryId"); + + b.ToTable("Products"); + + b.HasData( + new + { + ProductId = 1, + CategoryId = 1, + Description = "A simple mass produced keyboard", + Name = "Dell Keyboard" + }, + new + { + ProductId = 2, + CategoryId = 2, + Description = "A very expensive video card", + Name = "RTX 5090" + }, + new + { + ProductId = 3, + CategoryId = 3, + Description = "An enterprise widescreen monitor", + Name = "Dell Widescreen Monitor" + }, + new + { + ProductId = 4, + CategoryId = 4, + Description = "Western Digital Black Edition SSD", + Name = "WD Black Edition SSD" + }); + }); + + modelBuilder.Entity("CCMovieDatabase.Models.Rating", b => + { + b.Property("RatingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("RatingId")); + + b.Property("Name") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("RatingId"); + + b.ToTable("Ratings"); + + b.HasData( + new + { + RatingId = 1, + Name = "PG-13" + }, + new + { + RatingId = 2, + Name = "R" + }, + new + { + RatingId = 3, + Name = "G" + }); + }); + + modelBuilder.Entity("CCMovieDatabase.Models.ActingCredit", b => + { + b.HasOne("CCMovieDatabase.Models.Character", "Character") + .WithMany() + .HasForeignKey("CharacterId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("CCMovieDatabase.Models.Person", "Person") + .WithMany("ActingCredits") + .HasForeignKey("PersonId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Character"); + + b.Navigation("Person"); + }); + + modelBuilder.Entity("CCMovieDatabase.Models.Character", b => + { + b.HasOne("CCMovieDatabase.Models.Movie", "Movie") + .WithMany("Characters") + .HasForeignKey("MovieId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Movie"); + }); + + modelBuilder.Entity("CCMovieDatabase.Models.CrewCredit", b => + { + b.HasOne("CCMovieDatabase.Models.Movie", "Movie") + .WithMany() + .HasForeignKey("MovieId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("CCMovieDatabase.Models.Person", "Person") + .WithMany("CrewCredits") + .HasForeignKey("PersonId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Movie"); + + b.Navigation("Person"); + }); + + modelBuilder.Entity("CCMovieDatabase.Models.Movie", b => + { + b.HasOne("CCMovieDatabase.Models.Rating", "Rating") + .WithMany() + .HasForeignKey("RatingId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Rating"); + }); + + modelBuilder.Entity("CCMovieDatabase.Models.Product", b => + { + b.HasOne("CCMovieDatabase.Models.Category", "Category") + .WithMany("Products") + .HasForeignKey("CategoryId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Category"); + }); + + modelBuilder.Entity("CCMovieDatabase.Models.Category", b => + { + b.Navigation("Products"); + }); + + modelBuilder.Entity("CCMovieDatabase.Models.Movie", b => + { + b.Navigation("Characters"); + }); + + modelBuilder.Entity("CCMovieDatabase.Models.Person", b => + { + b.Navigation("ActingCredits"); + + b.Navigation("CrewCredits"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/CCMovieDatabase/Migrations/20251206034948_MovieSeedData.cs b/CCMovieDatabase/Migrations/20251206034948_MovieSeedData.cs new file mode 100644 index 0000000..9f09283 --- /dev/null +++ b/CCMovieDatabase/Migrations/20251206034948_MovieSeedData.cs @@ -0,0 +1,58 @@ +using System; +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +#pragma warning disable CA1814 // Prefer jagged arrays over multidimensional + +namespace CCMovieDatabase.Migrations +{ + /// + public partial class MovieSeedData : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.InsertData( + table: "Movie", + columns: new[] { "Id", "Description", "RatingId", "ReleaseDate", "ThumbnailURL", "Title" }, + values: new object[,] + { + { 3, "A world-class playboy and part-time secret agent from the 1960s emerges after thirty years in a cryogenic state to battle with his nemesis Dr. Evil.", 1, new DateOnly(1997, 5, 2), "https://encrypted-tbn2.gstatic.com/images?q=tbn:ANd9GcTlO5X0VeATdsHkdAiSqrIjnibxUZFxHvr56dYDONVdRyNsdJyhhAgLl7cMeUZX_nJL1szd1r0PWHMyHtWNoVVvP1FZNLZ6-A", "Austin Powers: International Man of Mystery" }, + { 4, "Dr. Evil is back and has invented a new time machine that allows him to go back to the 1960s and steal Austin Powers' mojo, inadvertently leaving him \"shagless\".", 1, new DateOnly(1999, 6, 11), "https://encrypted-tbn2.gstatic.com/images?q=tbn:ANd9GcSIfeD5mGXpWtcfJ_ycbhE_9ZAqnEugZyaEOd9vnjZYPipvpQq2olg1Bl2uyE6N_VcV7L0cnGIGgg8WqQD-fRo-USv7_4lLeQ", "Austin Powers: The Spy Who Shagged Me" }, + { 5, "Upon learning that his father has been kidnapped, Austin Powers must travel to 1975 and defeat the aptly named villain Goldmember, who is working with Dr. Evil.", 1, new DateOnly(2002, 7, 26), "https://static.qobuz.com/images/covers/66/49/0081227784966_600.jpg", "Austin Powers in Goldmember" }, + { 6, "A troubled security guard begins working at Freddy Fazbear's Pizza. During his five nights on the job, he realizes that something is wrong with the pizzeria and pretty soon finds the truth about its animatronics.", 1, new DateOnly(2023, 10, 27), "https://encrypted-tbn1.gstatic.com/images?q=tbn:ANd9GcTaydvBSSHZ_qYRr2QlfuisPN1JxzqmasvFmmuhCn9-vLzw6D1cY7NXscySkTHC80g2ASZKzSi2ATEICdak16TVc_kxIkeXFA", "Five Nights at Freddy's" }, + { 7, "Anyone can survive five nights. This time, there will be no second chances.", 1, new DateOnly(2025, 12, 5), "https://encrypted-tbn3.gstatic.com/images?q=tbn:ANd9GcQlGcWZganGfskXyYsVD1UMZmtaXp2y7nlxqJlWXAkAMSRYG6QgGZ-OCUAt77g7EC5Md-gD-7Ht8mV2OKFLj-nPQjUPW5a9DA", "Five Nights ar Freddy's 2" } + }); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DeleteData( + table: "Movie", + keyColumn: "Id", + keyValue: 3); + + migrationBuilder.DeleteData( + table: "Movie", + keyColumn: "Id", + keyValue: 4); + + migrationBuilder.DeleteData( + table: "Movie", + keyColumn: "Id", + keyValue: 5); + + migrationBuilder.DeleteData( + table: "Movie", + keyColumn: "Id", + keyValue: 6); + + migrationBuilder.DeleteData( + table: "Movie", + keyColumn: "Id", + keyValue: 7); + } + } +} diff --git a/CCMovieDatabase/Migrations/MovieContextModelSnapshot.cs b/CCMovieDatabase/Migrations/MovieContextModelSnapshot.cs index 727d985..123198f 100644 --- a/CCMovieDatabase/Migrations/MovieContextModelSnapshot.cs +++ b/CCMovieDatabase/Migrations/MovieContextModelSnapshot.cs @@ -283,6 +283,51 @@ protected override void BuildModel(ModelBuilder modelBuilder) ReleaseDate = new DateOnly(2002, 4, 26), ThumbnailURL = "https://encrypted-tbn3.gstatic.com/images?q=tbn:ANd9GcTPx7lW6h0G1O9-npEnVPL07fT74Tp6SFl0i47nxfypyVBcQFdS", Title = "Shrek 2" + }, + new + { + Id = 3, + Description = "A world-class playboy and part-time secret agent from the 1960s emerges after thirty years in a cryogenic state to battle with his nemesis Dr. Evil.", + RatingId = 1, + ReleaseDate = new DateOnly(1997, 5, 2), + ThumbnailURL = "https://encrypted-tbn2.gstatic.com/images?q=tbn:ANd9GcTlO5X0VeATdsHkdAiSqrIjnibxUZFxHvr56dYDONVdRyNsdJyhhAgLl7cMeUZX_nJL1szd1r0PWHMyHtWNoVVvP1FZNLZ6-A", + Title = "Austin Powers: International Man of Mystery" + }, + new + { + Id = 4, + Description = "Dr. Evil is back and has invented a new time machine that allows him to go back to the 1960s and steal Austin Powers' mojo, inadvertently leaving him \"shagless\".", + RatingId = 1, + ReleaseDate = new DateOnly(1999, 6, 11), + ThumbnailURL = "https://encrypted-tbn2.gstatic.com/images?q=tbn:ANd9GcSIfeD5mGXpWtcfJ_ycbhE_9ZAqnEugZyaEOd9vnjZYPipvpQq2olg1Bl2uyE6N_VcV7L0cnGIGgg8WqQD-fRo-USv7_4lLeQ", + Title = "Austin Powers: The Spy Who Shagged Me" + }, + new + { + Id = 5, + Description = "Upon learning that his father has been kidnapped, Austin Powers must travel to 1975 and defeat the aptly named villain Goldmember, who is working with Dr. Evil.", + RatingId = 1, + ReleaseDate = new DateOnly(2002, 7, 26), + ThumbnailURL = "https://static.qobuz.com/images/covers/66/49/0081227784966_600.jpg", + Title = "Austin Powers in Goldmember" + }, + new + { + Id = 6, + Description = "A troubled security guard begins working at Freddy Fazbear's Pizza. During his five nights on the job, he realizes that something is wrong with the pizzeria and pretty soon finds the truth about its animatronics.", + RatingId = 1, + ReleaseDate = new DateOnly(2023, 10, 27), + ThumbnailURL = "https://encrypted-tbn1.gstatic.com/images?q=tbn:ANd9GcTaydvBSSHZ_qYRr2QlfuisPN1JxzqmasvFmmuhCn9-vLzw6D1cY7NXscySkTHC80g2ASZKzSi2ATEICdak16TVc_kxIkeXFA", + Title = "Five Nights at Freddy's" + }, + new + { + Id = 7, + Description = "Anyone can survive five nights. This time, there will be no second chances.", + RatingId = 1, + ReleaseDate = new DateOnly(2025, 12, 5), + ThumbnailURL = "https://encrypted-tbn3.gstatic.com/images?q=tbn:ANd9GcQlGcWZganGfskXyYsVD1UMZmtaXp2y7nlxqJlWXAkAMSRYG6QgGZ-OCUAt77g7EC5Md-gD-7Ht8mV2OKFLj-nPQjUPW5a9DA", + Title = "Five Nights ar Freddy's 2" }); }); diff --git a/CCMovieDatabase/Views/ChristianList/Create.cshtml b/CCMovieDatabase/Views/ChristianList/Create.cshtml new file mode 100644 index 0000000..76eb97e --- /dev/null +++ b/CCMovieDatabase/Views/ChristianList/Create.cshtml @@ -0,0 +1,49 @@ +@model CCMovieDatabase.Models.Movie + +@{ + ViewData["Title"] = "Create"; +} + +

Create

+ +

Movie

+
+
+
+
+
+
+ + + +
+
+ + + +
+
+ + + +
+
+ + +
+
+ + + +
+
+ +
+
+
+
+ + + diff --git a/CCMovieDatabase/Views/ChristianList/Delete.cshtml b/CCMovieDatabase/Views/ChristianList/Delete.cshtml new file mode 100644 index 0000000..c8ce47f --- /dev/null +++ b/CCMovieDatabase/Views/ChristianList/Delete.cshtml @@ -0,0 +1,51 @@ +@model CCMovieDatabase.Models.Movie + +@{ + ViewData["Title"] = "Delete"; +} + +

Delete

+ +

Are you sure you want to delete this?

+
+

Movie

+
+
+
+ @Html.DisplayNameFor(model => model.Title) +
+
+ @Html.DisplayFor(model => model.Title) +
+
+ @Html.DisplayNameFor(model => model.Description) +
+
+ @Html.DisplayFor(model => model.Description) +
+
+ @Html.DisplayNameFor(model => model.ReleaseDate) +
+
+ @Html.DisplayFor(model => model.ReleaseDate) +
+
+ @Html.DisplayNameFor(model => model.ThumbnailURL) +
+
+ @Html.DisplayFor(model => model.ThumbnailURL) +
+
+ @Html.DisplayNameFor(model => model.Rating) +
+
+ @Html.DisplayFor(model => model.Rating.RatingId) +
+
+ +
+ + | + Back to List +
+
diff --git a/CCMovieDatabase/Views/ChristianList/Details.cshtml b/CCMovieDatabase/Views/ChristianList/Details.cshtml new file mode 100644 index 0000000..4a1b638 --- /dev/null +++ b/CCMovieDatabase/Views/ChristianList/Details.cshtml @@ -0,0 +1,55 @@ +@model CCMovieDatabase.Models.Movie + +@{ + ViewData["Title"] = "Details"; +} + +

Details

+ +
+

Movie

+
+
+
+ @Html.DisplayNameFor(model => model.Title) +
+
+ @Html.DisplayFor(model => model.Title) +
+
+ @Html.DisplayNameFor(model => model.Description) +
+
+ @Html.DisplayFor(model => model.Description) +
+
+ @Html.DisplayNameFor(model => model.ReleaseDate) +
+
+ @Html.DisplayFor(model => model.ReleaseDate) +
+
+ @Html.DisplayNameFor(model => model.ThumbnailURL) +
+
+ @Html.DisplayFor(model => model.ThumbnailURL) +
+
+ @Html.DisplayNameFor(model => model.Rating) +
+
+ @Html.DisplayFor(model => model.Rating.RatingId) +
+
+
+

@Model.Title

+ + + +

Released: @Model.ReleaseDate

+ +

@Model.Description

+ diff --git a/CCMovieDatabase/Views/ChristianList/Edit.cshtml b/CCMovieDatabase/Views/ChristianList/Edit.cshtml new file mode 100644 index 0000000..18b0167 --- /dev/null +++ b/CCMovieDatabase/Views/ChristianList/Edit.cshtml @@ -0,0 +1,51 @@ +@model CCMovieDatabase.Models.Movie + +@{ + ViewData["Title"] = "Edit"; +} + +

Edit

+ +

Movie

+
+
+
+
+
+ +
+ + + +
+
+ + + +
+
+ + + +
+
+ + + +
+
+ + + +
+
+ +
+
+
+
+ + + diff --git a/CCMovieDatabase/Views/ChristianList/Index.cshtml b/CCMovieDatabase/Views/ChristianList/Index.cshtml new file mode 100644 index 0000000..baf2399 --- /dev/null +++ b/CCMovieDatabase/Views/ChristianList/Index.cshtml @@ -0,0 +1,78 @@ +@model IEnumerable + +@{ + ViewData["Title"] = "Index"; +} + +

Favorite Movies

+ +
+ @foreach (var movie in Model) + { +
+
+ @movie.Title +
+
@movie.Title
+ + Details + +
+
+
+ } +
+ +

Index

+ +

+ Create New +

+ + + + + + + + + + + + +@foreach (var item in Model) { + + + + + + + + +} + +
+ @Html.DisplayNameFor(model => model.Title) + + @Html.DisplayNameFor(model => model.Description) + + @Html.DisplayNameFor(model => model.ReleaseDate) + + @Html.DisplayNameFor(model => model.ThumbnailURL) + + @Html.DisplayNameFor(model => model.Rating) +
+ @Html.DisplayFor(modelItem => item.Title) + + @Html.DisplayFor(modelItem => item.Description) + + @Html.DisplayFor(modelItem => item.ReleaseDate) + + @Html.DisplayFor(modelItem => item.ThumbnailURL) + + @Html.DisplayFor(modelItem => item.Rating.RatingId) + + Edit | + Details | + Delete +
diff --git a/CCMovieDatabase/Views/Shared/_Layout.cshtml b/CCMovieDatabase/Views/Shared/_Layout.cshtml index e4479e4..dadafec 100644 --- a/CCMovieDatabase/Views/Shared/_Layout.cshtml +++ b/CCMovieDatabase/Views/Shared/_Layout.cshtml @@ -38,6 +38,9 @@ +