public bool InsertMovie(string name, string storageLocation, DateTime releaseDate, string genre, int runTimeinMinutes, decimal budget, decimal revenue, string homePage, string overview, string castDetails) { using (var db = new MyMediaDBEntities()) { var movie = new Movie() { Name = name, StorageLocation = storageLocation, ReleaseDate = releaseDate, Genre = genre, RunTimeMinutes = runTimeinMinutes, Budget = budget, Revenue = revenue, HomePage = homePage, Overview = overview, CastDetails = castDetails }; db.Entry(movie).State = EntityState.Added; db.Movies.Add(movie); int result = db.SaveChanges(); if (result > 0) { return(true); } else { return(false); } } }
public bool UpdateMovie(int id, string name, string storageLocation, DateTime releaseDate, string genre, int runTimeinMinutes, decimal budget, decimal revenue, string homePage, string overview, string castDetails) { using (var db = new MyMediaDBEntities()) { var movie = new Movie { Id = id }; movie.Name = name; movie.StorageLocation = storageLocation; movie.ReleaseDate = releaseDate; movie.Genre = genre; movie.RunTimeMinutes = runTimeinMinutes; movie.Budget = budget; movie.Revenue = revenue; movie.HomePage = homePage; movie.Overview = overview; movie.CastDetails = castDetails; db.Entry(movie).State = EntityState.Modified; int result = db.SaveChanges(); if (result > 0) { return(true); } else { return(false); } } }
public bool DeleteMovie(int id) { using (var db = new MyMediaDBEntities()) { var movie = new Movie { Id = id }; db.Entry(movie).State = EntityState.Deleted; int result = db.SaveChanges(); if (result > 0) { return(true); } else { return(false); } } }