public static List<FilmModel> GetAllFilms() { using (var db = new SaitContext()) { return db.Films.ToList(); } }
public static void InsertFilm(FilmModel film) { using (var db = new SaitContext()) { db.Films.Add(film); db.SaveChanges(); } }
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(); } }
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; } } }