From e08bd3e3a4f242b06ef80c3a9e85bf8c72f7b97a Mon Sep 17 00:00:00 2001 From: cody norwood Date: Mon, 20 Oct 2025 11:30:51 -0700 Subject: [PATCH 1/5] Added Movie controller --- CCMovieDatabase/CCMovieDatabase.csproj | 9 ++ CCMovieDatabase/CCMovieDatabase.csproj.user | 10 ++ .../Controllers/MoviesController.cs | 108 ++++++++++++++++++ CCMovieDatabase/Data/MovieContext.cs | 19 +++ CCMovieDatabase/Program.cs | 5 + .../Properties/serviceDependencies.json | 8 ++ .../Properties/serviceDependencies.local.json | 8 ++ .../serviceDependencies.local.json.user | 9 ++ CCMovieDatabase/appsettings.json | 7 +- 9 files changed, 181 insertions(+), 2 deletions(-) create mode 100644 CCMovieDatabase/Controllers/MoviesController.cs create mode 100644 CCMovieDatabase/Data/MovieContext.cs create mode 100644 CCMovieDatabase/Properties/serviceDependencies.json create mode 100644 CCMovieDatabase/Properties/serviceDependencies.local.json create mode 100644 CCMovieDatabase/Properties/serviceDependencies.local.json.user diff --git a/CCMovieDatabase/CCMovieDatabase.csproj b/CCMovieDatabase/CCMovieDatabase.csproj index 6568b3d..0d1281d 100644 --- a/CCMovieDatabase/CCMovieDatabase.csproj +++ b/CCMovieDatabase/CCMovieDatabase.csproj @@ -6,4 +6,13 @@ enable + + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + + diff --git a/CCMovieDatabase/CCMovieDatabase.csproj.user b/CCMovieDatabase/CCMovieDatabase.csproj.user index 9ff5820..5d5f8b3 100644 --- a/CCMovieDatabase/CCMovieDatabase.csproj.user +++ b/CCMovieDatabase/CCMovieDatabase.csproj.user @@ -2,5 +2,15 @@ https + <_SelectedScaffolderID>ApiControllerWithContextScaffolder + <_SelectedScaffolderCategoryPath>root/Common + 650 + 650 + True + False + True + + CCMovieDatabase.Data.MovieContext + False \ No newline at end of file diff --git a/CCMovieDatabase/Controllers/MoviesController.cs b/CCMovieDatabase/Controllers/MoviesController.cs new file mode 100644 index 0000000..2823301 --- /dev/null +++ b/CCMovieDatabase/Controllers/MoviesController.cs @@ -0,0 +1,108 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.Mvc; +using Microsoft.EntityFrameworkCore; +using CCMovieDatabase.Data; +using CCMovieDatabase.Models; + +namespace CCMovieDatabase.Controllers +{ + [Route("api/[controller]")] + [ApiController] + public class MoviesController : ControllerBase + { + private readonly MovieContext _context; + + public MoviesController(MovieContext context) + { + _context = context; + } + + // GET: api/Movies + [HttpGet] + public async Task>> GetMovie() + { + return await _context.Movie.ToListAsync(); + } + + // GET: api/Movies/5 + [HttpGet("{id}")] + public async Task> GetMovie(int id) + { + var movie = await _context.Movie.FindAsync(id); + + if (movie == null) + { + return NotFound(); + } + + return movie; + } + + // PUT: api/Movies/5 + // To protect from overposting attacks, see https://go.microsoft.com/fwlink/?linkid=2123754 + [HttpPut("{id}")] + public async Task PutMovie(int id, Movie movie) + { + if (id != movie.Id) + { + return BadRequest(); + } + + _context.Entry(movie).State = EntityState.Modified; + + try + { + await _context.SaveChangesAsync(); + } + catch (DbUpdateConcurrencyException) + { + if (!MovieExists(id)) + { + return NotFound(); + } + else + { + throw; + } + } + + return NoContent(); + } + + // POST: api/Movies + // To protect from overposting attacks, see https://go.microsoft.com/fwlink/?linkid=2123754 + [HttpPost] + public async Task> PostMovie(Movie movie) + { + _context.Movie.Add(movie); + await _context.SaveChangesAsync(); + + return CreatedAtAction("GetMovie", new { id = movie.Id }, movie); + } + + // DELETE: api/Movies/5 + [HttpDelete("{id}")] + public async Task DeleteMovie(int id) + { + var movie = await _context.Movie.FindAsync(id); + if (movie == null) + { + return NotFound(); + } + + _context.Movie.Remove(movie); + await _context.SaveChangesAsync(); + + return NoContent(); + } + + 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 new file mode 100644 index 0000000..fd9b095 --- /dev/null +++ b/CCMovieDatabase/Data/MovieContext.cs @@ -0,0 +1,19 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using Microsoft.EntityFrameworkCore; +using CCMovieDatabase.Models; + +namespace CCMovieDatabase.Data +{ + public class MovieContext : DbContext + { + public MovieContext (DbContextOptions options) + : base(options) + { + } + + public DbSet Movie { get; set; } = default!; + } +} diff --git a/CCMovieDatabase/Program.cs b/CCMovieDatabase/Program.cs index 6941d46..b6507f0 100644 --- a/CCMovieDatabase/Program.cs +++ b/CCMovieDatabase/Program.cs @@ -1,3 +1,6 @@ +using Microsoft.EntityFrameworkCore; +using Microsoft.Extensions.DependencyInjection; +using CCMovieDatabase.Data; namespace CCMovieDatabase { public class Program @@ -5,6 +8,8 @@ public class Program public static void Main(string[] args) { var builder = WebApplication.CreateBuilder(args); + builder.Services.AddDbContext(options => + options.UseSqlServer(builder.Configuration.GetConnectionString("MovieContext") ?? throw new InvalidOperationException("Connection string 'MovieContext' not found."))); // Add services to the container. builder.Services.AddControllersWithViews(); diff --git a/CCMovieDatabase/Properties/serviceDependencies.json b/CCMovieDatabase/Properties/serviceDependencies.json new file mode 100644 index 0000000..02651c7 --- /dev/null +++ b/CCMovieDatabase/Properties/serviceDependencies.json @@ -0,0 +1,8 @@ +{ + "dependencies": { + "mssql1": { + "type": "mssql", + "connectionId": "ConnectionStrings:MovieContext" + } + } +} \ No newline at end of file diff --git a/CCMovieDatabase/Properties/serviceDependencies.local.json b/CCMovieDatabase/Properties/serviceDependencies.local.json new file mode 100644 index 0000000..e3bc465 --- /dev/null +++ b/CCMovieDatabase/Properties/serviceDependencies.local.json @@ -0,0 +1,8 @@ +{ + "dependencies": { + "mssql1": { + "type": "mssql.local", + "connectionId": "ConnectionStrings:MovieContext" + } + } +} \ No newline at end of file diff --git a/CCMovieDatabase/Properties/serviceDependencies.local.json.user b/CCMovieDatabase/Properties/serviceDependencies.local.json.user new file mode 100644 index 0000000..613cc29 --- /dev/null +++ b/CCMovieDatabase/Properties/serviceDependencies.local.json.user @@ -0,0 +1,9 @@ +{ + "dependencies": { + "mssql1": { + "restored": true, + "restoreTime": "2025-10-20T18:25:03.9493041Z" + } + }, + "parameters": {} +} \ No newline at end of file diff --git a/CCMovieDatabase/appsettings.json b/CCMovieDatabase/appsettings.json index 10f68b8..b63e4ac 100644 --- a/CCMovieDatabase/appsettings.json +++ b/CCMovieDatabase/appsettings.json @@ -5,5 +5,8 @@ "Microsoft.AspNetCore": "Warning" } }, - "AllowedHosts": "*" -} + "AllowedHosts": "*", + "ConnectionStrings": { + "MovieContext": "Server=(localdb)\\mssqllocaldb;Database=MovieContext-58bc998f-a17b-4d6d-a156-276a4193d6a5;Trusted_Connection=True;MultipleActiveResultSets=true" + } +} \ No newline at end of file From ed6681095a95718db9ce39769a362f8fcf926468 Mon Sep 17 00:00:00 2001 From: Cody Norwood Date: Mon, 1 Dec 2025 08:10:35 -0800 Subject: [PATCH 2/5] Added new items --- CCMovieDatabase/Controllers/CodyController.cs | 166 ++++++++++++++++++ CCMovieDatabase/Data/MovieContext.cs | 8 +- .../20251126220201_Added5movies.Designer.cs | 145 +++++++++++++++ .../Migrations/20251126220201_Added5movies.cs | 74 ++++++++ .../Migrations/MovieContextModelSnapshot.cs | 36 +++- CCMovieDatabase/Views/Cody/Create.cshtml | 47 +++++ CCMovieDatabase/Views/Cody/Delete.cshtml | 45 +++++ CCMovieDatabase/Views/Cody/Details.cshtml | 42 +++++ CCMovieDatabase/Views/Cody/Edit.cshtml | 49 ++++++ CCMovieDatabase/Views/Cody/Index.cshtml | 129 ++++++++++++++ CCMovieDatabase/Views/Shared/_Layout.cshtml | 8 + 11 files changed, 740 insertions(+), 9 deletions(-) create mode 100644 CCMovieDatabase/Controllers/CodyController.cs create mode 100644 CCMovieDatabase/Migrations/20251126220201_Added5movies.Designer.cs create mode 100644 CCMovieDatabase/Migrations/20251126220201_Added5movies.cs create mode 100644 CCMovieDatabase/Views/Cody/Create.cshtml create mode 100644 CCMovieDatabase/Views/Cody/Delete.cshtml create mode 100644 CCMovieDatabase/Views/Cody/Details.cshtml create mode 100644 CCMovieDatabase/Views/Cody/Edit.cshtml create mode 100644 CCMovieDatabase/Views/Cody/Index.cshtml diff --git a/CCMovieDatabase/Controllers/CodyController.cs b/CCMovieDatabase/Controllers/CodyController.cs new file mode 100644 index 0000000..b88dcb2 --- /dev/null +++ b/CCMovieDatabase/Controllers/CodyController.cs @@ -0,0 +1,166 @@ +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 CodyController : Controller + { + private readonly MovieContext _context; + + public CodyController(MovieContext context) + { + _context = context; + } + + // GET: Cody + public async Task Index() + { + //var movieContext = _context.Movie.Include(m => m.Rating); + //return View(await movieContext.ToListAsync()); + var movies = _context.Movie.Take(5).ToList(); + return View(movies); + } + + // GET: Cody/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: Cody/Create + public IActionResult Create() + { + ViewData["RatingId"] = new SelectList(_context.Ratings, "RatingId", "RatingId"); + return View(); + } + + // POST: Cody/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")] 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: Cody/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: Cody/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")] 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: Cody/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: Cody/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 3d2cf98..13b5b5f 100644 --- a/CCMovieDatabase/Data/MovieContext.cs +++ b/CCMovieDatabase/Data/MovieContext.cs @@ -32,9 +32,11 @@ protected override void OnModelCreating(ModelBuilder modelBuilder) // 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 = "Men in Black", ReleaseDate = new DateOnly(1997,7,25), Description = "James, an NYC cop, is hired by Agent K of a secret government agency that monitors extraterrestrial life on Earth. Together, they must recover an item that has been stolen by an intergalactic villain.", RatingId = 1 }, + new Movie { Id = 2, Title = "Avatar: The Way of Water", ReleaseDate = new DateOnly(2022, 12, 16), Description = "Jake Sully lives with his newfound family formed on the extrasolar moon Pandora. Once a familiar threat returns to finish what was previously started, Jake must work with Neytiri and the army of the Na'vi race to protect their home.", RatingId = 1 }, + new Movie { Id = 3, Title = "Avengers: Infinity War", ReleaseDate = new DateOnly(2018, 4, 23), Description = "The Avengers and their allies must be willing to sacrifice all in an attempt to defeat the powerful Thanos before his blitz of devastation and ruin puts an end to the universe.", RatingId = 1}, + new Movie { Id = 4, Title = "Ratatouille", ReleaseDate = new DateOnly(2007,6,28), Description = "A rat who can cook makes an unusual alliance with a young kitchen worker at a famous Paris restaurant.", RatingId = 3}, + new Movie { Id = 5, Title = "Monsters, Inc.", ReleaseDate = new DateOnly(2001,10,28), Description = "In order to power the city, monsters have to scare children so that they scream. However, the children are toxic to the monsters, and after a child gets through, two monsters realize things may not be what they think", RatingId = 3} }; modelBuilder.Entity().HasData(movies); diff --git a/CCMovieDatabase/Migrations/20251126220201_Added5movies.Designer.cs b/CCMovieDatabase/Migrations/20251126220201_Added5movies.Designer.cs new file mode 100644 index 0000000..12c75c8 --- /dev/null +++ b/CCMovieDatabase/Migrations/20251126220201_Added5movies.Designer.cs @@ -0,0 +1,145 @@ +// +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("20251126220201_Added5movies")] + partial class Added5movies + { + /// + 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.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 = "James, an NYC cop, is hired by Agent K of a secret government agency that monitors extraterrestrial life on Earth. Together, they must recover an item that has been stolen by an intergalactic villain.", + RatingId = 1, + ReleaseDate = new DateOnly(1997, 7, 25), + Title = "Men in Black" + }, + new + { + Id = 2, + Description = "Jake Sully lives with his newfound family formed on the extrasolar moon Pandora. Once a familiar threat returns to finish what was previously started, Jake must work with Neytiri and the army of the Na'vi race to protect their home.", + RatingId = 1, + ReleaseDate = new DateOnly(2022, 12, 16), + Title = "Avatar: The Way of Water" + }, + new + { + Id = 3, + Description = "The Avengers and their allies must be willing to sacrifice all in an attempt to defeat the powerful Thanos before his blitz of devastation and ruin puts an end to the universe.", + RatingId = 1, + ReleaseDate = new DateOnly(2018, 4, 23), + Title = "Avengers: Infinity War" + }, + new + { + Id = 4, + Description = "A rat who can cook makes an unusual alliance with a young kitchen worker at a famous Paris restaurant.", + RatingId = 3, + ReleaseDate = new DateOnly(2007, 6, 28), + Title = "Ratatouille" + }, + new + { + Id = 5, + Description = "In order to power the city, monsters have to scare children so that they scream. However, the children are toxic to the monsters, and after a child gets through, two monsters realize things may not be what they think", + RatingId = 3, + ReleaseDate = new DateOnly(2001, 10, 28), + Title = "Monsters, Inc." + }); + }); + + 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.Movie", b => + { + b.HasOne("CCMovieDatabase.Models.Rating", "Rating") + .WithMany() + .HasForeignKey("RatingId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Rating"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/CCMovieDatabase/Migrations/20251126220201_Added5movies.cs b/CCMovieDatabase/Migrations/20251126220201_Added5movies.cs new file mode 100644 index 0000000..d411b10 --- /dev/null +++ b/CCMovieDatabase/Migrations/20251126220201_Added5movies.cs @@ -0,0 +1,74 @@ +using System; +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +#pragma warning disable CA1814 // Prefer jagged arrays over multidimensional + +namespace CCMovieDatabase.Migrations +{ + /// + public partial class Added5movies : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.UpdateData( + table: "Movie", + keyColumn: "Id", + keyValue: 1, + columns: new[] { "Description", "ReleaseDate", "Title" }, + values: new object[] { "James, an NYC cop, is hired by Agent K of a secret government agency that monitors extraterrestrial life on Earth. Together, they must recover an item that has been stolen by an intergalactic villain.", new DateOnly(1997, 7, 25), "Men in Black" }); + + migrationBuilder.UpdateData( + table: "Movie", + keyColumn: "Id", + keyValue: 2, + columns: new[] { "Description", "ReleaseDate", "Title" }, + values: new object[] { "Jake Sully lives with his newfound family formed on the extrasolar moon Pandora. Once a familiar threat returns to finish what was previously started, Jake must work with Neytiri and the army of the Na'vi race to protect their home.", new DateOnly(2022, 12, 16), "Avatar: The Way of Water" }); + + migrationBuilder.InsertData( + table: "Movie", + columns: new[] { "Id", "Description", "RatingId", "ReleaseDate", "Title" }, + values: new object[,] + { + { 3, "The Avengers and their allies must be willing to sacrifice all in an attempt to defeat the powerful Thanos before his blitz of devastation and ruin puts an end to the universe.", 1, new DateOnly(2018, 4, 23), "Avengers: Infinity War" }, + { 4, "A rat who can cook makes an unusual alliance with a young kitchen worker at a famous Paris restaurant.", 3, new DateOnly(2007, 6, 28), "Ratatouille" }, + { 5, "In order to power the city, monsters have to scare children so that they scream. However, the children are toxic to the monsters, and after a child gets through, two monsters realize things may not be what they think", 3, new DateOnly(2001, 10, 28), "Monsters, Inc." } + }); + } + + /// + 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.UpdateData( + table: "Movie", + keyColumn: "Id", + keyValue: 1, + columns: new[] { "Description", "ReleaseDate", "Title" }, + values: new object[] { "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.", new DateOnly(2001, 4, 26), "Shrek" }); + + migrationBuilder.UpdateData( + table: "Movie", + keyColumn: "Id", + keyValue: 2, + columns: new[] { "Description", "ReleaseDate", "Title" }, + values: new object[] { "Shrek is back baby!", new DateOnly(2002, 4, 26), "Shrek 2" }); + } + } +} diff --git a/CCMovieDatabase/Migrations/MovieContextModelSnapshot.cs b/CCMovieDatabase/Migrations/MovieContextModelSnapshot.cs index 71b42de..eea79ff 100644 --- a/CCMovieDatabase/Migrations/MovieContextModelSnapshot.cs +++ b/CCMovieDatabase/Migrations/MovieContextModelSnapshot.cs @@ -53,18 +53,42 @@ protected override void BuildModel(ModelBuilder modelBuilder) 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.", + Description = "James, an NYC cop, is hired by Agent K of a secret government agency that monitors extraterrestrial life on Earth. Together, they must recover an item that has been stolen by an intergalactic villain.", RatingId = 1, - ReleaseDate = new DateOnly(2001, 4, 26), - Title = "Shrek" + ReleaseDate = new DateOnly(1997, 7, 25), + Title = "Men in Black" }, new { Id = 2, - Description = "Shrek is back baby!", + Description = "Jake Sully lives with his newfound family formed on the extrasolar moon Pandora. Once a familiar threat returns to finish what was previously started, Jake must work with Neytiri and the army of the Na'vi race to protect their home.", RatingId = 1, - ReleaseDate = new DateOnly(2002, 4, 26), - Title = "Shrek 2" + ReleaseDate = new DateOnly(2022, 12, 16), + Title = "Avatar: The Way of Water" + }, + new + { + Id = 3, + Description = "The Avengers and their allies must be willing to sacrifice all in an attempt to defeat the powerful Thanos before his blitz of devastation and ruin puts an end to the universe.", + RatingId = 1, + ReleaseDate = new DateOnly(2018, 4, 23), + Title = "Avengers: Infinity War" + }, + new + { + Id = 4, + Description = "A rat who can cook makes an unusual alliance with a young kitchen worker at a famous Paris restaurant.", + RatingId = 3, + ReleaseDate = new DateOnly(2007, 6, 28), + Title = "Ratatouille" + }, + new + { + Id = 5, + Description = "In order to power the city, monsters have to scare children so that they scream. However, the children are toxic to the monsters, and after a child gets through, two monsters realize things may not be what they think", + RatingId = 3, + ReleaseDate = new DateOnly(2001, 10, 28), + Title = "Monsters, Inc." }); }); diff --git a/CCMovieDatabase/Views/Cody/Create.cshtml b/CCMovieDatabase/Views/Cody/Create.cshtml new file mode 100644 index 0000000..c81c6b9 --- /dev/null +++ b/CCMovieDatabase/Views/Cody/Create.cshtml @@ -0,0 +1,47 @@ +@model CCMovieDatabase.Models.Movie + +@{ + ViewData["Title"] = "Create"; +} + +

Create

+ +

Movie

+
+
+
+
+
+
+ + + +
+
+ + + +
+
+ + + +
+
+ + +
+
+ +
+
+
+
+ + + +@section Scripts { + @{await Html.RenderPartialAsync("_ValidationScriptsPartial");} +} diff --git a/CCMovieDatabase/Views/Cody/Delete.cshtml b/CCMovieDatabase/Views/Cody/Delete.cshtml new file mode 100644 index 0000000..bca40d8 --- /dev/null +++ b/CCMovieDatabase/Views/Cody/Delete.cshtml @@ -0,0 +1,45 @@ +@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.Rating) +
+
+ @Html.DisplayFor(model => model.Rating.RatingId) +
+
+ +
+ + | + Back to List +
+
diff --git a/CCMovieDatabase/Views/Cody/Details.cshtml b/CCMovieDatabase/Views/Cody/Details.cshtml new file mode 100644 index 0000000..1e74d7f --- /dev/null +++ b/CCMovieDatabase/Views/Cody/Details.cshtml @@ -0,0 +1,42 @@ +@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.Rating) +
+
+ @Html.DisplayFor(model => model.Rating.RatingId) +
+
+
+ diff --git a/CCMovieDatabase/Views/Cody/Edit.cshtml b/CCMovieDatabase/Views/Cody/Edit.cshtml new file mode 100644 index 0000000..6c3d428 --- /dev/null +++ b/CCMovieDatabase/Views/Cody/Edit.cshtml @@ -0,0 +1,49 @@ +@model CCMovieDatabase.Models.Movie + +@{ + ViewData["Title"] = "Edit"; +} + +

Edit

+ +

Movie

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

Cody's movie editor

+ +@*
+ Card image cap +
+
@Html.DisplayFor()
+

Some quick example text to build on the card title and make up the bulk of the card's content.

+ Go somewhere +
+
*@ + +
+ + +
+ +
+ Card image cap +
+
Men in Black
+

+ Details +
+
+ +
+
+
+ Card image cap +
+
Avatar: The Way of Water
+

+ Details +
+
+ +
+
+
+ Card image cap +
+
Avengers: Infinity War
+

+ Details +
+
+ +
+
+
+ Card image cap +
+
Ratatouille
+

+ Details +
+
+ +
+
+
+ Card image cap +
+
Monsters, Inc.
+

+ Details +
+
+ +
+ + +
+ + + + +@* +

+ 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.Rating) +
+ @Html.DisplayFor(modelItem => item.Title) + + @Html.DisplayFor(modelItem => item.Description) + + @Html.DisplayFor(modelItem => item.ReleaseDate) + + @Html.DisplayFor(modelItem => item.Rating.RatingId) + + Edit | + Details | + Delete +
*@ diff --git a/CCMovieDatabase/Views/Shared/_Layout.cshtml b/CCMovieDatabase/Views/Shared/_Layout.cshtml index 7123acd..bed9548 100644 --- a/CCMovieDatabase/Views/Shared/_Layout.cshtml +++ b/CCMovieDatabase/Views/Shared/_Layout.cshtml @@ -26,6 +26,14 @@ + +