public ActionResult Sessions() { var model = new SessionsPageModel() { Films = _db.FilmSet.AsEnumerable().ToList(), FilmSessions = _db.FilmSessionSet.AsEnumerable().ToList() }; return(View(model)); }
public ActionResult Delete(int filmID) { _db.FilmSet.Remove(_db.FilmSet.Where(f => f.FilmID == filmID).FirstOrDefault()); _db.SaveChanges(); var model = new SessionsPageModel() { Films = _db.FilmSet.AsEnumerable().ToList(), FilmSessions = _db.FilmSessionSet.AsEnumerable().ToList() }; return(View("Sessions", model)); }
public ActionResult Added(AddPageModel model1) { var addedFilm = model1.Film; addedFilm.AgeRating = _db.AgeRatingSet.Where(r => r.Title == model1.SelectedAgeRating).FirstOrDefault(); addedFilm.Genre = _db.GenreSet.Where(r => r.Title == model1.SelectedGenre).FirstOrDefault(); addedFilm.ImagePath = "32ds"; _db.FilmSet.Add(addedFilm); _db.SaveChanges(); var model = new SessionsPageModel() { Films = _db.FilmSet.AsEnumerable().ToList(), FilmSessions = _db.FilmSessionSet.AsEnumerable().ToList() }; return(View("Sessions", model)); }
public ActionResult Edited(EditPageModel model1) { var editedFilm = model1.Film; editedFilm.AgeRating = _db.AgeRatingSet.Where(r => r.Title == model1.SelectedAgeRating).FirstOrDefault(); editedFilm.Genre = _db.GenreSet.Where(r => r.Title == model1.SelectedGenre).FirstOrDefault(); var uneditedFilm = _db.FilmSet.Where(t => t.FilmID == editedFilm.FilmID).FirstOrDefault(); #region params uneditedFilm.Title = editedFilm.Title; uneditedFilm.Country = editedFilm.Country; uneditedFilm.TimeLength = editedFilm.TimeLength; uneditedFilm.ImagePath = editedFilm.ImagePath; uneditedFilm.Description = editedFilm.Description; uneditedFilm.MoreGenres = editedFilm.MoreGenres; uneditedFilm.Actors = editedFilm.Actors; uneditedFilm.Producer = editedFilm.Producer; uneditedFilm.KinopoiskLink = editedFilm.KinopoiskLink; uneditedFilm.Genre = editedFilm.Genre; uneditedFilm.AgeRating = editedFilm.AgeRating; #endregion _db.SaveChanges(); var model = new SessionsPageModel() { Films = _db.FilmSet.AsEnumerable().ToList(), FilmSessions = _db.FilmSessionSet.AsEnumerable().ToList() }; return(View("Sessions", model)); }