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