示例#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);
        }