Esempio n. 1
0
        /// <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);
            }
        }
Esempio n. 2
0
        /// <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);
        }