예제 #1
0
파일: Movie.cs 프로젝트: beqasmile/BSOOP1
        /// <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);
            }
        }
예제 #2
0
파일: Movie.cs 프로젝트: beqasmile/BSOOP1
        /// <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);
        }