public void Add(Genre genre) { //Create the queries ctx.Genres.Add(genre); //Execute the queries ctx.SaveChanges(); }
public void Add(Genre genre) { using (var ctx = new MovieShopContext()) { // create queries ctx.Genres.Add(genre); // execute changes ctx.SaveChanges(); } }
public Genre Delete(Genre genre) { using (var ctx = new MovieShopContextDB()) { var genreDB = ctx.Genres.FirstOrDefault(item => item.Id == genre.Id); ctx.Genres.Remove(genreDB); ctx.SaveChanges(); return genre; } }
public Genre Update(Genre genre) { using (var ctx = new MovieShopContextDB()) { var genreDB = ctx.Genres.FirstOrDefault(item => item.Id == genre.Id); genreDB.Name = genre.Name; genreDB.Movies = genre.Movies; ctx.SaveChanges(); return genre; } }
public void Update(Genre genre) { using (var ctx = new MovieShopContext()) { var genreToUpdate = ctx.Genres.Where(x => x.Id == genre.Id).FirstOrDefault(); if (genreToUpdate != null) { genreToUpdate.Name = genre.Name; ctx.SaveChanges(); } } }
public Genre Add(Genre genre) { using (var ctx = new MovieShopContextDB()) { //Create the queries ctx.Genres.Add(genre); //Execute the queries ctx.SaveChanges(); return genre; } }
public void Remove(Genre genre) { try { using (var ctx = new MovieShopContext()) { var genreToDelete = ctx.Genres.Where(x => x.Id == genre.Id).FirstOrDefault(); ctx.Genres.Remove(genreToDelete); ctx.SaveChanges(); } } catch (DbUpdateException ex) { throw new Exception("This Genre exists in a movie and can not be deleted"); } }
public ActionResult DeleteConfirmed(Genre genre) { facade.GetGenreRepository().Delete(genre); return RedirectToAction("Index"); }
public ActionResult Create(Genre genre) { facade.GetGenreRepository().Add(genre); return Redirect("Create"); }