public static void DeleteFromDb(Film favoriteFilm) { using (var db = new FilmsContext()) { if (favoriteFilm != null) { db.Films.Remove(db.Films.First(film => film.Title == favoriteFilm.Title)); } db.SaveChanges(); } }
public static void SaveFavoriteFilm(Film favoriteFilm) { using (var db = new FilmsContext()) { if (db.Films.Count(film => film.Title == favoriteFilm.Title) == 0) { db.Films.Add(favoriteFilm); } db.SaveChanges(); } }