Exemplo n.º 1
0
 public void InsertOrUpdate(Movie movie)
 {
     if (movie.ID == default(int)) {
         // New entity
         context.Movies.Add(movie);
     } else {
         // Existing entity
         context.Entry(movie).State = EntityState.Modified;
     }
 }
Exemplo n.º 2
0
 public ActionResult Create(Movie movie)
 {
     if (ModelState.IsValid) {
         movieRepository.InsertOrUpdate(movie);
         movieRepository.Save();
         return RedirectToAction("Index");
     } else {
         ViewBag.PossibleDirectors = directorRepository.All;
         ViewBag.PossibleCountries = countryRepository.All;
         return View();
     }
 }