public void Remove(Movie movie) { using (var ctx = new ShopContextConnectionString()) { ctx.Movies.Attach(movie); ctx.Movies.Remove(movie); ctx.SaveChanges(); } }
public Movie Add(Movie item) { using (var ctx = new ShopContextConnectionString()) { ctx.Movies.Attach(item); ctx.Movies.Add(item); ctx.SaveChanges(); } return(item); }
public Genre Add(Genre item) { using (var ctx = new ShopContextConnectionString()) { //Create the queries ctx.Genres.Add(item); //Execute the queries ctx.SaveChanges(); } return(item); }
public bool Update(Movie item) { using (var ctx = new ShopContextConnectionString()) { //A gift to Lars from KBTZ team. Enjoy! var movieDB = ctx.Movies.FirstOrDefault(x => x.Id == item.Id); movieDB.Genre = ctx.Genres.FirstOrDefault(x => x.Id == item.Genre.Id); movieDB.Title = item.Title; movieDB.Price = item.Price; movieDB.Year = item.Year; movieDB.Description = item.Description; movieDB.url = item.url; movieDB.MovieCoverUrl = item.MovieCoverUrl; ctx.SaveChanges(); } return(true); }