/// <summary> /// Add actor to the movies list /// </summary> /// <param name="movieActor"></param> public void AddActor(MovieActor movieActor) { bool actorFound = false; foreach (MovieActor item in this.movieActorsList) { if (item.Id == movieActor.Id) { Console.WriteLine("Actor already exists and can not be added twice"); actorFound = true; } } if (!actorFound) { this.movieActorsList.Add(movieActor); } }
/// <summary> /// Removes actor from the movies list /// </summary> /// <param name="actorId"></param> /// <returns></returns> public MovieActor RemoveActorByID(int actorId) { MovieActor actorToRemove = null; foreach (MovieActor item in this.movieActorsList) { if (item.Id == actorId) { actorToRemove = item; } } if (actorToRemove != null) { this.movieActorsList.Remove(actorToRemove); } return(actorToRemove); }