コード例 #1
0
        public ActionResult Create(Movie movieToCreate)
        {
            if (ModelState.IsValid) {

                context.Movies.Add(movieToCreate);
                context.SaveChanges();

                return RedirectToAction("Index");
            }
            return View(movieToCreate);
        }
コード例 #2
0
        public ActionResult Edit(Movie movieToEdit)
        {
            if (ModelState.IsValid) {

                //var originalMovie = context.Movies.Find(movieToEdit.MovieId);

                //originalMovie.UserName = this.User.Identity.Name;

                //orignalMovie.Director = movieToEdit.Director;

                context.Entry(movieToEdit).State = System.Data.EntityState.Modified;
                context.SaveChanges();

                return RedirectToAction("Index");
            }

            return View(movieToEdit);
        }