Exemple #1
0
        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();
            }
        }
Exemple #2
0
        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();
            }
        }