public static bool RemoveFilm(this DBEntities DB, FilmView filmView) { Film film = DB.Films.Find(filmView.Id); BeginTransaction(DB); SetFilmCastings(DB, film.Id, null); DB.Films.Remove(film); DB.SaveChanges(); Commit(); return(true); }
public static bool UpdateFilm(this DBEntities DB, FilmView filmView, List <int> actorsIdList) { Film film = DB.Films.Find(filmView.Id); filmView.ToFilm(film); BeginTransaction(DB); DB.Entry(film).State = EntityState.Modified; DB.SaveChanges(); SetFilmCastings(DB, film.Id, actorsIdList); Commit(); return(true); }
public static FilmView AddFilm(this DBEntities DB, FilmView filmView, List <int> actorsIdList) { Film film = new Film(); filmView.ToFilm(film); BeginTransaction(DB); film = DB.Films.Add(film); DB.SaveChanges(); SetFilmCastings(DB, film.Id, actorsIdList); Commit(); return(film.ToFilmView()); }