public void AddMovie(Movie movieToAdd) { using (var db = new MovieReviewsEntities()) { db.Movies.Add(movieToAdd); db.SaveChanges(); } }
public void AddActor(Actor actorToAdd) { using (var db = new MovieReviewsEntities()) { db.Actors.Add(actorToAdd); db.SaveChanges(); } }
public void UpdateActor(Actor actorToEdit) { using (var db = new MovieReviewsEntities()) { db.Actors.Attach(actorToEdit); db.Entry<Actor>(actorToEdit).State = System.Data.EntityState.Modified; db.SaveChanges(); } }
public ActionResult Add(MovieReview model) { using (var db = new MovieReviewsEntities()) { db.MovieReviews.Add(model); db.SaveChanges(); } return RedirectToAction("index", new { movieId = model.MovieID }); //How do I return this to a view operated by a different controller? Or would I never really want to? }
public void DeleteActor(int actorId) { using (var db = new MovieReviewsEntities()) { var actorToDelete = new Actor { ActorID = actorId }; db.Actors.Attach(actorToDelete); db.Actors.Remove(actorToDelete); db.SaveChanges(); } }
public void addActorToMovie(int movieId, int actorId) { MovieActor movieActorEntity = new MovieActor { MovieID = movieId, ActorID = actorId }; using (var db = new MovieReviewsEntities()) { db.MovieActors.Add(movieActorEntity); db.SaveChanges(); } }
public void Delete(int movieId) { using (var db = new MovieReviewsEntities()) { var movieToDelete = new Movie { MovieID = movieId }; db.Movies.Attach(movieToDelete); db.Movies.Remove(movieToDelete); db.SaveChanges(); } }
public ActionResult Delete(int moviereviewId) { using (var db = new MovieReviewsEntities()) { var reviewToDelete = new MovieReview { MovieReviewID = moviereviewId }; db.MovieReviews.Attach(reviewToDelete); db.MovieReviews.Remove(reviewToDelete); db.SaveChanges(); } return RedirectToAction("Index"); }
public int removeActorFrommovie(int movieId, int actorId) { MovieActor actorToRemoveFromMovie = new MovieActor(); using (var db = new MovieReviewsEntities()) { actorToRemoveFromMovie.MovieActorID = db.MovieActors.First(m => m.MovieID == movieId & m.ActorID == actorId).MovieActorID; //} //using (var db = new MovieReviewsEntities()) //{ // //listOfActors = db.MovieActors.Where(ma => ma.MovieID == movieId).Select(ma => ma.Actor).ToList(); //db.MovieActors.Attach(actorToRemoveFromMovie); db.MovieActors.Remove(actorToRemoveFromMovie); db.SaveChanges(); } return actorToRemoveFromMovie.MovieID; }
public void Update(Movie movieToUpdate) { using (var db = new MovieReviewsEntities()) { db.Movies.Attach(movieToUpdate); db.Entry<Movie>(movieToUpdate).State = System.Data.EntityState.Modified; db.SaveChanges(); } }