Пример #1
0
 public static List<FilmModel> GetAllFilms()
 {
     using (var db = new SaitContext())
     {
         return db.Films.ToList();
     }
 }
Пример #2
0
 public static void InsertFilm(FilmModel film)
 {
     using (var db = new SaitContext())
     {
         db.Films.Add(film);
         db.SaveChanges();
     }
 }
Пример #3
0
 public static void DeleteFilm(int id)
 {
     using (var db = new SaitContext())
     {
         var id_f = db.Films.First(x => x.Id == id);
         db.Films.Remove(id_f);
         db.SaveChanges();
     }
 }
Пример #4
0
        public static List<FilmModel> GetFilter(SearchModel searchModel)
        {
            using (var db = new SaitContext())
            {
                var allFilms = DAO.WorkFilms.GetAllFilms();

                if (searchModel == null)
                {
                    return allFilms;
                }
                else
                {
                    var FilterSpisok = allFilms.Where(x => x.ChooseGenre == searchModel.genre).ToList();
                    if (searchModel.year > 0)
                    {
                        var our_year = new DateTime(searchModel.year, 1, 1);
                        FilterSpisok = FilterSpisok.Where(mod => mod.DataFilms > our_year).ToList();
                    }

                    return FilterSpisok;
                }
            }
        }