예제 #1
0
        public ActionResult AddMovie()
        {
            ViewBag.Message = "Add New Movie:";
            Movie model = new Movie();

            return View(model);
        }
예제 #2
0
 public ActionResult AddMovie(Movie model)
 {
     using (ApplicationDbContext db = new ApplicationDbContext())
     {
         Movie NewMovie = new Movie()
         {
             MovieId = model.MovieId,
             Title = model.Title,
             Year = model.Year,
             Genre = model.Genre,
             Rating = model.Rating
         };
         db.Movies.Add(NewMovie);
         db.SaveChanges();
     }
     return RedirectToAction("Index");
 }
예제 #3
0
 public ActionResult EditMovie(Movie model)
 {
     using (ApplicationDbContext db = new ApplicationDbContext())
     {
         Movie movie = db.Movies.FirstOrDefault(x => x.MovieId == model.MovieId);
         movie.Title = model.Title;
         movie.Year = model.Year;
         movie.Genre = model.Genre;
         movie.Rating = model.Rating;
         db.SaveChanges();
     }
     return RedirectToAction("Details", new { id = model.MovieId });
 }