Beispiel #1
0
 public static List <Film> GetAllFilms()
 {
     using (var db = new FilmsContext())
     {
         return(db.Films.ToList());
     }
 }
Beispiel #2
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();
            }
        }
Beispiel #3
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();
            }
        }