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 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; }