diff --git a/CCMovieDatabase/Controllers/MoviesController.cs b/CCMovieDatabase/Controllers/MoviesController.cs index 137b8af..4ec3a56 100644 --- a/CCMovieDatabase/Controllers/MoviesController.cs +++ b/CCMovieDatabase/Controllers/MoviesController.cs @@ -57,7 +57,7 @@ public IActionResult Create() // For more details, see http://go.microsoft.com/fwlink/?LinkId=317598. [HttpPost] [ValidateAntiForgeryToken] - public async Task Create([Bind("Id,Title,Description,ReleaseDate,RatingId")] Movie movie) + public async Task Create([Bind("Id,Title,Description,ReleaseDate,RatingId,ThumbnailURL")] Movie movie) { if (ModelState.IsValid) { @@ -91,7 +91,7 @@ public async Task Edit(int? id) // 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")] Movie movie) + public async Task Edit(int id, [Bind("Id,Title,Description,ReleaseDate,RatingId,ThumbnailURL")] Movie movie) { if (id != movie.Id) { diff --git a/CCMovieDatabase/Controllers/PorterListController.cs b/CCMovieDatabase/Controllers/PorterListController.cs new file mode 100644 index 0000000..9eb321d --- /dev/null +++ b/CCMovieDatabase/Controllers/PorterListController.cs @@ -0,0 +1,167 @@ +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 PorterListController : Controller + { + private readonly MovieContext _context; + + public PorterListController(MovieContext context) + { + _context = context; + } + + // GET: PorterList + public async Task Index() + { + var movieContext = _context.Movie + .Include(m => m.Rating) + .Skip(2) + .Take(5); + return View(await movieContext.ToListAsync()); + } + + // GET: PorterList/Details/5 + public async Task Details(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); + } + + // GET: PorterList/Create + public IActionResult Create() + { + ViewData["RatingId"] = new SelectList(_context.Ratings, "RatingId", "RatingId"); + return View(); + } + + // POST: PorterList/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: PorterList/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: PorterList/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: PorterList/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: PorterList/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 9eea68c..e9efe10 100644 --- a/CCMovieDatabase/Data/MovieContext.cs +++ b/CCMovieDatabase/Data/MovieContext.cs @@ -31,15 +31,21 @@ protected override void OnModelCreating(ModelBuilder modelBuilder) { new Rating { RatingId = 1, Name = "PG-13" }, new Rating { RatingId = 2, Name = "R" }, - new Rating { RatingId = 3, Name = "G" } + new Rating { RatingId = 3, Name = "G" }, + new Rating { RatingId = 4, Name = "PG" } }; modelBuilder.Entity().HasData(ratings); // right here we seed data var movies = new List { - 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 }, - new Movie { Id = 2, Title = "Shrek 2", ReleaseDate = new DateOnly(2002, 04, 26), Description = "Shrek is back baby!", RatingId = 1 }, + 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 = "Harry Potter and the Sorcerer's Stone", ReleaseDate = new DateOnly(2001,01,01), Description = "An orphaned boy enrolls in a school of wizardry, where he learns the truth about himself, his family and the terrible evil that haunts the magical world.", RatingId = 4, ThumbnailURL = "https://encrypted-tbn2.gstatic.com/images?q=tbn:ANd9GcQcZT3sdwr1NiJytvJb95icJJKPWpWRNv35l_uuVYxjlzBJS-hb" }, + new Movie { Id = 4, Title = "Toy Story", ReleaseDate = new DateOnly(1995,01,01), Description = "A cowboy doll is profoundly jealous when a new spaceman action figure supplants him as the top toy in a boy's bedroom.", RatingId = 3, ThumbnailURL = "https://m.media-amazon.com/images/M/MV5BZTA3OWVjOWItNjE1NS00NzZiLWE1MjgtZDZhMWI1ZTlkNzYwXkEyXkFqcGc@._V1_.jpg" }, + new Movie { Id = 5, Title = "A Christmas Story", ReleaseDate = new DateOnly(1983,01,01), Description = "In the 1940s, a young boy named Ralphie Parker attempts to convince his parents, teacher, and Santa Claus that a Red Ryder Range 200 Shot BB gun really is the perfect Christmas gift.", RatingId = 4, ThumbnailURL = "https://encrypted-tbn1.gstatic.com/images?q=tbn:ANd9GcSUZk92ju8kisZKCc9m4lyySg9S5RSM6mhFnSWOpOb1_MlCsHsw" }, + new Movie { Id = 6, Title = "Elf", ReleaseDate = new DateOnly(2003,01,01), Description = "Raised as an oversized elf, Buddy travels from the North Pole to New York City to meet his biological father, Walter Hobbs, who doesn't know he exists and is in desperate need of some Christmas spirit.", RatingId = 4, ThumbnailURL = "https://encrypted-tbn2.gstatic.com/images?q=tbn:ANd9GcT08ZFpbAwAL_jQFtQfMjut1_T6oNgxRCQiOPA6S1twJLXZq_Wi" }, + new Movie { Id = 7, Title = "Weapons", ReleaseDate = new DateOnly(2025,01,01), Description = "When all but one child from the same class mysteriously vanish on the same night at exactly the same time, a community is left questioning who or what is behind their disappearance.", RatingId = 2, ThumbnailURL = "https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcR84Bm2XnTfW7hukdkEdr5jezVGfoIt22h0-s7Dfk1aRavoPZmh" } }; diff --git a/CCMovieDatabase/Migrations/20251201191148_AddedSeededMoviesForTop5.Designer.cs b/CCMovieDatabase/Migrations/20251201191148_AddedSeededMoviesForTop5.Designer.cs new file mode 100644 index 0000000..a9985aa --- /dev/null +++ b/CCMovieDatabase/Migrations/20251201191148_AddedSeededMoviesForTop5.Designer.cs @@ -0,0 +1,416 @@ +// +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("20251201191148_AddedSeededMoviesForTop5")] + partial class AddedSeededMoviesForTop5 + { + /// + 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.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("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), + Title = "Shrek" + }, + new + { + Id = 2, + Description = "Shrek is back baby!", + RatingId = 1, + ReleaseDate = new DateOnly(2002, 4, 26), + Title = "Shrek 2" + }, + new + { + Id = 3, + Description = "An orphaned boy enrolls in a school of wizardry, where he learns the truth about himself, his family and the terrible evil that haunts the magical world.", + RatingId = 1, + ReleaseDate = new DateOnly(2001, 1, 1), + Title = "Harry Potter and the Sorcerer's Stone" + }, + new + { + Id = 4, + Description = "A cowboy doll is profoundly jealous when a new spaceman action figure supplants him as the top toy in a boy's bedroom.", + RatingId = 3, + ReleaseDate = new DateOnly(1995, 1, 1), + Title = "Toy Story" + }, + new + { + Id = 5, + Description = "In the 1940s, a young boy named Ralphie Parker attempts to convince his parents, teacher, and Santa Claus that a Red Ryder Range 200 Shot BB gun really is the perfect Christmas gift.", + RatingId = 1, + ReleaseDate = new DateOnly(1983, 1, 1), + Title = "A Christmas Story" + }, + new + { + Id = 6, + Description = "Raised as an oversized elf, Buddy travels from the North Pole to New York City to meet his biological father, Walter Hobbs, who doesn't know he exists and is in desperate need of some Christmas spirit.", + RatingId = 1, + ReleaseDate = new DateOnly(2003, 1, 1), + Title = "Elf" + }, + new + { + Id = 7, + Description = "When all but one child from the same class mysteriously vanish on the same night at exactly the same time, a community is left questioning who or what is behind their disappearance.", + RatingId = 2, + ReleaseDate = new DateOnly(2025, 1, 1), + Title = "Weapons" + }); + }); + + 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.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.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/20251201191148_AddedSeededMoviesForTop5.cs b/CCMovieDatabase/Migrations/20251201191148_AddedSeededMoviesForTop5.cs new file mode 100644 index 0000000..cb58d1f --- /dev/null +++ b/CCMovieDatabase/Migrations/20251201191148_AddedSeededMoviesForTop5.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 AddedSeededMoviesForTop5 : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.InsertData( + table: "Movie", + columns: new[] { "Id", "Description", "RatingId", "ReleaseDate", "Title" }, + values: new object[,] + { + { 3, "An orphaned boy enrolls in a school of wizardry, where he learns the truth about himself, his family and the terrible evil that haunts the magical world.", 1, new DateOnly(2001, 1, 1), "Harry Potter and the Sorcerer's Stone" }, + { 4, "A cowboy doll is profoundly jealous when a new spaceman action figure supplants him as the top toy in a boy's bedroom.", 3, new DateOnly(1995, 1, 1), "Toy Story" }, + { 5, "In the 1940s, a young boy named Ralphie Parker attempts to convince his parents, teacher, and Santa Claus that a Red Ryder Range 200 Shot BB gun really is the perfect Christmas gift.", 1, new DateOnly(1983, 1, 1), "A Christmas Story" }, + { 6, "Raised as an oversized elf, Buddy travels from the North Pole to New York City to meet his biological father, Walter Hobbs, who doesn't know he exists and is in desperate need of some Christmas spirit.", 1, new DateOnly(2003, 1, 1), "Elf" }, + { 7, "When all but one child from the same class mysteriously vanish on the same night at exactly the same time, a community is left questioning who or what is behind their disappearance.", 2, new DateOnly(2025, 1, 1), "Weapons" } + }); + } + + /// + 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/20251202193443_AddedPGRating.Designer.cs b/CCMovieDatabase/Migrations/20251202193443_AddedPGRating.Designer.cs new file mode 100644 index 0000000..ba36fbd --- /dev/null +++ b/CCMovieDatabase/Migrations/20251202193443_AddedPGRating.Designer.cs @@ -0,0 +1,431 @@ +// +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("20251202193443_AddedPGRating")] + partial class AddedPGRating + { + /// + 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.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 = "An orphaned boy enrolls in a school of wizardry, where he learns the truth about himself, his family and the terrible evil that haunts the magical world.", + RatingId = 1, + ReleaseDate = new DateOnly(2001, 1, 1), + ThumbnailURL = "https://encrypted-tbn2.gstatic.com/images?q=tbn:ANd9GcQcZT3sdwr1NiJytvJb95icJJKPWpWRNv35l_uuVYxjlzBJS-hb", + Title = "Harry Potter and the Sorcerer's Stone" + }, + new + { + Id = 4, + Description = "A cowboy doll is profoundly jealous when a new spaceman action figure supplants him as the top toy in a boy's bedroom.", + RatingId = 3, + ReleaseDate = new DateOnly(1995, 1, 1), + ThumbnailURL = "https://encrypted-tbn3.gstatic.com/images?q=tbn:ANd9GcRw1ynxwA6p8jGMs5TD1Q6BFgn9fafEk-XQ3lrYQGQo0q4Ggo3a", + Title = "Toy Story" + }, + new + { + Id = 5, + Description = "In the 1940s, a young boy named Ralphie Parker attempts to convince his parents, teacher, and Santa Claus that a Red Ryder Range 200 Shot BB gun really is the perfect Christmas gift.", + RatingId = 1, + ReleaseDate = new DateOnly(1983, 1, 1), + ThumbnailURL = "https://encrypted-tbn1.gstatic.com/images?q=tbn:ANd9GcSUZk92ju8kisZKCc9m4lyySg9S5RSM6mhFnSWOpOb1_MlCsHsw", + Title = "A Christmas Story" + }, + new + { + Id = 6, + Description = "Raised as an oversized elf, Buddy travels from the North Pole to New York City to meet his biological father, Walter Hobbs, who doesn't know he exists and is in desperate need of some Christmas spirit.", + RatingId = 1, + ReleaseDate = new DateOnly(2003, 1, 1), + ThumbnailURL = "https://encrypted-tbn2.gstatic.com/images?q=tbn:ANd9GcT08ZFpbAwAL_jQFtQfMjut1_T6oNgxRCQiOPA6S1twJLXZq_Wi", + Title = "Elf" + }, + new + { + Id = 7, + Description = "When all but one child from the same class mysteriously vanish on the same night at exactly the same time, a community is left questioning who or what is behind their disappearance.", + RatingId = 2, + ReleaseDate = new DateOnly(2025, 1, 1), + ThumbnailURL = "https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcR84Bm2XnTfW7hukdkEdr5jezVGfoIt22h0-s7Dfk1aRavoPZmh", + Title = "Weapons" + }); + }); + + 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.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" + }, + new + { + RatingId = 4, + Name = "PG" + }); + }); + + 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.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/20251202193443_AddedPGRating.cs b/CCMovieDatabase/Migrations/20251202193443_AddedPGRating.cs new file mode 100644 index 0000000..5ec3f23 --- /dev/null +++ b/CCMovieDatabase/Migrations/20251202193443_AddedPGRating.cs @@ -0,0 +1,87 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace CCMovieDatabase.Migrations +{ + /// + public partial class AddedPGRating : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.AddColumn( + name: "ThumbnailURL", + table: "Movie", + type: "nvarchar(max)", + nullable: true); + + migrationBuilder.UpdateData( + table: "Movie", + keyColumn: "Id", + keyValue: 1, + column: "ThumbnailURL", + value: "https://encrypted-tbn1.gstatic.com/images?q=tbn:ANd9GcTG_q0A0cypAsXxYlgs5J_554BrcnjeeKExlQE3ZaZUuPYv0fUd"); + + migrationBuilder.UpdateData( + table: "Movie", + keyColumn: "Id", + keyValue: 2, + column: "ThumbnailURL", + value: "https://encrypted-tbn3.gstatic.com/images?q=tbn:ANd9GcTPx7lW6h0G1O9-npEnVPL07fT74Tp6SFl0i47nxfypyVBcQFdS"); + + migrationBuilder.UpdateData( + table: "Movie", + keyColumn: "Id", + keyValue: 3, + column: "ThumbnailURL", + value: "https://encrypted-tbn2.gstatic.com/images?q=tbn:ANd9GcQcZT3sdwr1NiJytvJb95icJJKPWpWRNv35l_uuVYxjlzBJS-hb"); + + migrationBuilder.UpdateData( + table: "Movie", + keyColumn: "Id", + keyValue: 4, + column: "ThumbnailURL", + value: "https://encrypted-tbn3.gstatic.com/images?q=tbn:ANd9GcRw1ynxwA6p8jGMs5TD1Q6BFgn9fafEk-XQ3lrYQGQo0q4Ggo3a"); + + migrationBuilder.UpdateData( + table: "Movie", + keyColumn: "Id", + keyValue: 5, + column: "ThumbnailURL", + value: "https://encrypted-tbn1.gstatic.com/images?q=tbn:ANd9GcSUZk92ju8kisZKCc9m4lyySg9S5RSM6mhFnSWOpOb1_MlCsHsw"); + + migrationBuilder.UpdateData( + table: "Movie", + keyColumn: "Id", + keyValue: 6, + column: "ThumbnailURL", + value: "https://encrypted-tbn2.gstatic.com/images?q=tbn:ANd9GcT08ZFpbAwAL_jQFtQfMjut1_T6oNgxRCQiOPA6S1twJLXZq_Wi"); + + migrationBuilder.UpdateData( + table: "Movie", + keyColumn: "Id", + keyValue: 7, + column: "ThumbnailURL", + value: "https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcR84Bm2XnTfW7hukdkEdr5jezVGfoIt22h0-s7Dfk1aRavoPZmh"); + + migrationBuilder.InsertData( + table: "Ratings", + columns: new[] { "RatingId", "Name" }, + values: new object[] { 4, "PG" }); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DeleteData( + table: "Ratings", + keyColumn: "RatingId", + keyValue: 4); + + migrationBuilder.DropColumn( + name: "ThumbnailURL", + table: "Movie"); + } + } +} diff --git a/CCMovieDatabase/Migrations/20251202193547_ModifiedMovieRatings.Designer.cs b/CCMovieDatabase/Migrations/20251202193547_ModifiedMovieRatings.Designer.cs new file mode 100644 index 0000000..b18701d --- /dev/null +++ b/CCMovieDatabase/Migrations/20251202193547_ModifiedMovieRatings.Designer.cs @@ -0,0 +1,431 @@ +// +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("20251202193547_ModifiedMovieRatings")] + partial class ModifiedMovieRatings + { + /// + 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.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 = "An orphaned boy enrolls in a school of wizardry, where he learns the truth about himself, his family and the terrible evil that haunts the magical world.", + RatingId = 4, + ReleaseDate = new DateOnly(2001, 1, 1), + ThumbnailURL = "https://encrypted-tbn2.gstatic.com/images?q=tbn:ANd9GcQcZT3sdwr1NiJytvJb95icJJKPWpWRNv35l_uuVYxjlzBJS-hb", + Title = "Harry Potter and the Sorcerer's Stone" + }, + new + { + Id = 4, + Description = "A cowboy doll is profoundly jealous when a new spaceman action figure supplants him as the top toy in a boy's bedroom.", + RatingId = 3, + ReleaseDate = new DateOnly(1995, 1, 1), + ThumbnailURL = "https://encrypted-tbn3.gstatic.com/images?q=tbn:ANd9GcRw1ynxwA6p8jGMs5TD1Q6BFgn9fafEk-XQ3lrYQGQo0q4Ggo3a", + Title = "Toy Story" + }, + new + { + Id = 5, + Description = "In the 1940s, a young boy named Ralphie Parker attempts to convince his parents, teacher, and Santa Claus that a Red Ryder Range 200 Shot BB gun really is the perfect Christmas gift.", + RatingId = 4, + ReleaseDate = new DateOnly(1983, 1, 1), + ThumbnailURL = "https://encrypted-tbn1.gstatic.com/images?q=tbn:ANd9GcSUZk92ju8kisZKCc9m4lyySg9S5RSM6mhFnSWOpOb1_MlCsHsw", + Title = "A Christmas Story" + }, + new + { + Id = 6, + Description = "Raised as an oversized elf, Buddy travels from the North Pole to New York City to meet his biological father, Walter Hobbs, who doesn't know he exists and is in desperate need of some Christmas spirit.", + RatingId = 4, + ReleaseDate = new DateOnly(2003, 1, 1), + ThumbnailURL = "https://encrypted-tbn2.gstatic.com/images?q=tbn:ANd9GcT08ZFpbAwAL_jQFtQfMjut1_T6oNgxRCQiOPA6S1twJLXZq_Wi", + Title = "Elf" + }, + new + { + Id = 7, + Description = "When all but one child from the same class mysteriously vanish on the same night at exactly the same time, a community is left questioning who or what is behind their disappearance.", + RatingId = 2, + ReleaseDate = new DateOnly(2025, 1, 1), + ThumbnailURL = "https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcR84Bm2XnTfW7hukdkEdr5jezVGfoIt22h0-s7Dfk1aRavoPZmh", + Title = "Weapons" + }); + }); + + 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.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" + }, + new + { + RatingId = 4, + Name = "PG" + }); + }); + + 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.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/20251202193547_ModifiedMovieRatings.cs b/CCMovieDatabase/Migrations/20251202193547_ModifiedMovieRatings.cs new file mode 100644 index 0000000..2599cd7 --- /dev/null +++ b/CCMovieDatabase/Migrations/20251202193547_ModifiedMovieRatings.cs @@ -0,0 +1,60 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace CCMovieDatabase.Migrations +{ + /// + public partial class ModifiedMovieRatings : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.UpdateData( + table: "Movie", + keyColumn: "Id", + keyValue: 3, + column: "RatingId", + value: 4); + + migrationBuilder.UpdateData( + table: "Movie", + keyColumn: "Id", + keyValue: 5, + column: "RatingId", + value: 4); + + migrationBuilder.UpdateData( + table: "Movie", + keyColumn: "Id", + keyValue: 6, + column: "RatingId", + value: 4); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.UpdateData( + table: "Movie", + keyColumn: "Id", + keyValue: 3, + column: "RatingId", + value: 1); + + migrationBuilder.UpdateData( + table: "Movie", + keyColumn: "Id", + keyValue: 5, + column: "RatingId", + value: 1); + + migrationBuilder.UpdateData( + table: "Movie", + keyColumn: "Id", + keyValue: 6, + column: "RatingId", + value: 1); + } + } +} diff --git a/CCMovieDatabase/Migrations/20251203190234_ChangedToyStoryURL.Designer.cs b/CCMovieDatabase/Migrations/20251203190234_ChangedToyStoryURL.Designer.cs new file mode 100644 index 0000000..7c3ad97 --- /dev/null +++ b/CCMovieDatabase/Migrations/20251203190234_ChangedToyStoryURL.Designer.cs @@ -0,0 +1,431 @@ +// +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("20251203190234_ChangedToyStoryURL")] + partial class ChangedToyStoryURL + { + /// + 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.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 = "An orphaned boy enrolls in a school of wizardry, where he learns the truth about himself, his family and the terrible evil that haunts the magical world.", + RatingId = 4, + ReleaseDate = new DateOnly(2001, 1, 1), + ThumbnailURL = "https://encrypted-tbn2.gstatic.com/images?q=tbn:ANd9GcQcZT3sdwr1NiJytvJb95icJJKPWpWRNv35l_uuVYxjlzBJS-hb", + Title = "Harry Potter and the Sorcerer's Stone" + }, + new + { + Id = 4, + Description = "A cowboy doll is profoundly jealous when a new spaceman action figure supplants him as the top toy in a boy's bedroom.", + RatingId = 3, + ReleaseDate = new DateOnly(1995, 1, 1), + ThumbnailURL = "https://m.media-amazon.com/images/M/MV5BZTA3OWVjOWItNjE1NS00NzZiLWE1MjgtZDZhMWI1ZTlkNzYwXkEyXkFqcGc@._V1_.jpg", + Title = "Toy Story" + }, + new + { + Id = 5, + Description = "In the 1940s, a young boy named Ralphie Parker attempts to convince his parents, teacher, and Santa Claus that a Red Ryder Range 200 Shot BB gun really is the perfect Christmas gift.", + RatingId = 4, + ReleaseDate = new DateOnly(1983, 1, 1), + ThumbnailURL = "https://encrypted-tbn1.gstatic.com/images?q=tbn:ANd9GcSUZk92ju8kisZKCc9m4lyySg9S5RSM6mhFnSWOpOb1_MlCsHsw", + Title = "A Christmas Story" + }, + new + { + Id = 6, + Description = "Raised as an oversized elf, Buddy travels from the North Pole to New York City to meet his biological father, Walter Hobbs, who doesn't know he exists and is in desperate need of some Christmas spirit.", + RatingId = 4, + ReleaseDate = new DateOnly(2003, 1, 1), + ThumbnailURL = "https://encrypted-tbn2.gstatic.com/images?q=tbn:ANd9GcT08ZFpbAwAL_jQFtQfMjut1_T6oNgxRCQiOPA6S1twJLXZq_Wi", + Title = "Elf" + }, + new + { + Id = 7, + Description = "When all but one child from the same class mysteriously vanish on the same night at exactly the same time, a community is left questioning who or what is behind their disappearance.", + RatingId = 2, + ReleaseDate = new DateOnly(2025, 1, 1), + ThumbnailURL = "https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcR84Bm2XnTfW7hukdkEdr5jezVGfoIt22h0-s7Dfk1aRavoPZmh", + Title = "Weapons" + }); + }); + + 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.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" + }, + new + { + RatingId = 4, + Name = "PG" + }); + }); + + 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.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/20251203190234_ChangedToyStoryURL.cs b/CCMovieDatabase/Migrations/20251203190234_ChangedToyStoryURL.cs new file mode 100644 index 0000000..0bf3790 --- /dev/null +++ b/CCMovieDatabase/Migrations/20251203190234_ChangedToyStoryURL.cs @@ -0,0 +1,32 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace CCMovieDatabase.Migrations +{ + /// + public partial class ChangedToyStoryURL : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.UpdateData( + table: "Movie", + keyColumn: "Id", + keyValue: 4, + column: "ThumbnailURL", + value: "https://m.media-amazon.com/images/M/MV5BZTA3OWVjOWItNjE1NS00NzZiLWE1MjgtZDZhMWI1ZTlkNzYwXkEyXkFqcGc@._V1_.jpg"); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.UpdateData( + table: "Movie", + keyColumn: "Id", + keyValue: 4, + column: "ThumbnailURL", + value: "https://encrypted-tbn3.gstatic.com/images?q=tbn:ANd9GcRw1ynxwA6p8jGMs5TD1Q6BFgn9fafEk-XQ3lrYQGQo0q4Ggo3a"); + } + } +} diff --git a/CCMovieDatabase/Migrations/MovieContextModelSnapshot.cs b/CCMovieDatabase/Migrations/MovieContextModelSnapshot.cs index 1301e40..3fa59ca 100644 --- a/CCMovieDatabase/Migrations/MovieContextModelSnapshot.cs +++ b/CCMovieDatabase/Migrations/MovieContextModelSnapshot.cs @@ -213,6 +213,9 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.Property("ReleaseDate") .HasColumnType("date"); + b.Property("ThumbnailURL") + .HasColumnType("nvarchar(max)"); + b.Property("Title") .IsRequired() .HasColumnType("nvarchar(max)"); @@ -230,6 +233,7 @@ protected override void BuildModel(ModelBuilder modelBuilder) 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 @@ -238,7 +242,53 @@ protected override void BuildModel(ModelBuilder modelBuilder) 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 = "An orphaned boy enrolls in a school of wizardry, where he learns the truth about himself, his family and the terrible evil that haunts the magical world.", + RatingId = 4, + ReleaseDate = new DateOnly(2001, 1, 1), + ThumbnailURL = "https://encrypted-tbn2.gstatic.com/images?q=tbn:ANd9GcQcZT3sdwr1NiJytvJb95icJJKPWpWRNv35l_uuVYxjlzBJS-hb", + Title = "Harry Potter and the Sorcerer's Stone" + }, + new + { + Id = 4, + Description = "A cowboy doll is profoundly jealous when a new spaceman action figure supplants him as the top toy in a boy's bedroom.", + RatingId = 3, + ReleaseDate = new DateOnly(1995, 1, 1), + ThumbnailURL = "https://m.media-amazon.com/images/M/MV5BZTA3OWVjOWItNjE1NS00NzZiLWE1MjgtZDZhMWI1ZTlkNzYwXkEyXkFqcGc@._V1_.jpg", + Title = "Toy Story" + }, + new + { + Id = 5, + Description = "In the 1940s, a young boy named Ralphie Parker attempts to convince his parents, teacher, and Santa Claus that a Red Ryder Range 200 Shot BB gun really is the perfect Christmas gift.", + RatingId = 4, + ReleaseDate = new DateOnly(1983, 1, 1), + ThumbnailURL = "https://encrypted-tbn1.gstatic.com/images?q=tbn:ANd9GcSUZk92ju8kisZKCc9m4lyySg9S5RSM6mhFnSWOpOb1_MlCsHsw", + Title = "A Christmas Story" + }, + new + { + Id = 6, + Description = "Raised as an oversized elf, Buddy travels from the North Pole to New York City to meet his biological father, Walter Hobbs, who doesn't know he exists and is in desperate need of some Christmas spirit.", + RatingId = 4, + ReleaseDate = new DateOnly(2003, 1, 1), + ThumbnailURL = "https://encrypted-tbn2.gstatic.com/images?q=tbn:ANd9GcT08ZFpbAwAL_jQFtQfMjut1_T6oNgxRCQiOPA6S1twJLXZq_Wi", + Title = "Elf" + }, + new + { + Id = 7, + Description = "When all but one child from the same class mysteriously vanish on the same night at exactly the same time, a community is left questioning who or what is behind their disappearance.", + RatingId = 2, + ReleaseDate = new DateOnly(2025, 1, 1), + ThumbnailURL = "https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcR84Bm2XnTfW7hukdkEdr5jezVGfoIt22h0-s7Dfk1aRavoPZmh", + Title = "Weapons" }); }); @@ -293,6 +343,11 @@ protected override void BuildModel(ModelBuilder modelBuilder) { RatingId = 3, Name = "G" + }, + new + { + RatingId = 4, + Name = "PG" }); }); diff --git a/CCMovieDatabase/Models/Movie.cs b/CCMovieDatabase/Models/Movie.cs index 8c3feff..de19391 100644 --- a/CCMovieDatabase/Models/Movie.cs +++ b/CCMovieDatabase/Models/Movie.cs @@ -9,6 +9,7 @@ public class Movie // TODO: how do i relate data? genres public DateOnly ReleaseDate { get; set; } public int RatingId { get; set; } + public string? ThumbnailURL { get; set; } // navigation property public Rating Rating { get; set; } diff --git a/CCMovieDatabase/Views/Movies/Create.cshtml b/CCMovieDatabase/Views/Movies/Create.cshtml index c81c6b9..7fda2c8 100644 --- a/CCMovieDatabase/Views/Movies/Create.cshtml +++ b/CCMovieDatabase/Views/Movies/Create.cshtml @@ -31,6 +31,11 @@ +
+ + + +
diff --git a/CCMovieDatabase/Views/Movies/Delete.cshtml b/CCMovieDatabase/Views/Movies/Delete.cshtml index bca40d8..c8ce47f 100644 --- a/CCMovieDatabase/Views/Movies/Delete.cshtml +++ b/CCMovieDatabase/Views/Movies/Delete.cshtml @@ -29,6 +29,12 @@
@Html.DisplayFor(model => model.ReleaseDate)
+
+ @Html.DisplayNameFor(model => model.ThumbnailURL) +
+
+ @Html.DisplayFor(model => model.ThumbnailURL) +
@Html.DisplayNameFor(model => model.Rating)
diff --git a/CCMovieDatabase/Views/Movies/Details.cshtml b/CCMovieDatabase/Views/Movies/Details.cshtml index 1e74d7f..ba7197f 100644 --- a/CCMovieDatabase/Views/Movies/Details.cshtml +++ b/CCMovieDatabase/Views/Movies/Details.cshtml @@ -28,6 +28,12 @@
@Html.DisplayFor(model => model.ReleaseDate)
+
+ @Html.DisplayNameFor(model => model.ThumbnailURL) +
+
+ @Html.DisplayFor(model => model.ThumbnailURL) +
@Html.DisplayNameFor(model => model.Rating)
diff --git a/CCMovieDatabase/Views/Movies/Edit.cshtml b/CCMovieDatabase/Views/Movies/Edit.cshtml index 6c3d428..3ac2c75 100644 --- a/CCMovieDatabase/Views/Movies/Edit.cshtml +++ b/CCMovieDatabase/Views/Movies/Edit.cshtml @@ -33,6 +33,11 @@ +
+ + + +
diff --git a/CCMovieDatabase/Views/Movies/Index.cshtml b/CCMovieDatabase/Views/Movies/Index.cshtml index ef67ab5..edffcfa 100644 --- a/CCMovieDatabase/Views/Movies/Index.cshtml +++ b/CCMovieDatabase/Views/Movies/Index.cshtml @@ -4,7 +4,7 @@ ViewData["Title"] = "Index"; } -

@ViewData["Title"]

+

Index

Create New @@ -21,6 +21,9 @@ @Html.DisplayNameFor(model => model.ReleaseDate) + + @Html.DisplayNameFor(model => model.ThumbnailURL) + @Html.DisplayNameFor(model => model.Rating) @@ -39,6 +42,9 @@ @Html.DisplayFor(modelItem => item.ReleaseDate) + + @Html.DisplayFor(modelItem => item.ThumbnailURL) + @Html.DisplayFor(modelItem => item.Rating.RatingId) diff --git a/CCMovieDatabase/Views/PorterList/Create.cshtml b/CCMovieDatabase/Views/PorterList/Create.cshtml new file mode 100644 index 0000000..7fda2c8 --- /dev/null +++ b/CCMovieDatabase/Views/PorterList/Create.cshtml @@ -0,0 +1,52 @@ +@model CCMovieDatabase.Models.Movie + +@{ + ViewData["Title"] = "Create"; +} + +

Create

+ +

Movie

+
+
+
+
+
+
+ + + +
+
+ + + +
+
+ + + +
+
+ + +
+
+ + + +
+
+ +
+
+
+
+ + + +@section Scripts { + @{await Html.RenderPartialAsync("_ValidationScriptsPartial");} +} diff --git a/CCMovieDatabase/Views/PorterList/Delete.cshtml b/CCMovieDatabase/Views/PorterList/Delete.cshtml new file mode 100644 index 0000000..c8ce47f --- /dev/null +++ b/CCMovieDatabase/Views/PorterList/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/PorterList/Details.cshtml b/CCMovieDatabase/Views/PorterList/Details.cshtml new file mode 100644 index 0000000..41044de --- /dev/null +++ b/CCMovieDatabase/Views/PorterList/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) +
+
+ @if (Model.ThumbnailURL != null) + { + + } + else + { +

No Thumbnail

+ } +
+
+ @Html.DisplayNameFor(model => model.Rating) +
+
+ @Html.DisplayFor(model => model.Rating.RatingId) +
+
+
+ diff --git a/CCMovieDatabase/Views/PorterList/Edit.cshtml b/CCMovieDatabase/Views/PorterList/Edit.cshtml new file mode 100644 index 0000000..3ac2c75 --- /dev/null +++ b/CCMovieDatabase/Views/PorterList/Edit.cshtml @@ -0,0 +1,54 @@ +@model CCMovieDatabase.Models.Movie + +@{ + ViewData["Title"] = "Edit"; +} + +

Edit

+ +

Movie

+
+
+
+
+
+ +
+ + + +
+
+ + + +
+
+ + + +
+
+ + + +
+
+ + + +
+
+ +
+
+
+
+ + + +@section Scripts { + @{await Html.RenderPartialAsync("_ValidationScriptsPartial");} +} diff --git a/CCMovieDatabase/Views/PorterList/Index.cshtml b/CCMovieDatabase/Views/PorterList/Index.cshtml new file mode 100644 index 0000000..4853a4a --- /dev/null +++ b/CCMovieDatabase/Views/PorterList/Index.cshtml @@ -0,0 +1,107 @@ +@model IEnumerable + +@{ + ViewData["Title"] = "Index"; +} + +@*

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) + + @if (item.ThumbnailURL != null) + { + + } + else + { +

No Thumbnail

+ } +
+ @Html.DisplayFor(modelItem => item.Rating.RatingId) + + Edit | + Details | + Delete +
+ +*@ +
+ @foreach (var item in Model) + { + +
+ @item.ThumbnailURL +
+
@item.Title
+

@item.Description

+ Details +
+
+ } +
+ + + +@*
+ @foreach (var item in Model) + { +
+
+ @item.ThumbnailUrl +
+
@item.Title
+

@item.ShortDescription

+ Read More +
+
+
+ } +
+ +*@ \ No newline at end of file diff --git a/CCMovieDatabase/Views/Shared/_Layout.cshtml b/CCMovieDatabase/Views/Shared/_Layout.cshtml index 4f03822..2b434f5 100644 --- a/CCMovieDatabase/Views/Shared/_Layout.cshtml +++ b/CCMovieDatabase/Views/Shared/_Layout.cshtml @@ -35,6 +35,9 @@ +