예제 #1
0
 public ActionResult Create(Genre genre)
 {
     if (ModelState.IsValid) {
         genreRepository.InsertOrUpdate(genre);
         genreRepository.Save();
         return RedirectToAction("Index");
     } else {
         return View();
     }
 }
예제 #2
0
 public void InsertOrUpdate(Genre genre)
 {
     if (genre.GenreID == default(int)) {
         // New entity
         context.Genres.Add(genre);
     } else {
         // Existing entity
         context.Entry(genre).State = EntityState.Modified;
     }
 }