Esempio n. 1
0
 public void AddActor(Actor actor)
 {
     if (!Actors.Contains(actor))
     {
         Actors.Add(actor);
     }
 }
Esempio n. 2
0
 public override void OnNetworkDestroy()
 {
     if (Actors.Contains(this))
     {
         Actors.Remove(this);
     }
 }
Esempio n. 3
0
    public override void OnStartClient()
    {
        if (!Actors.Contains(this))
        {
            Actors.Add(this);
        }

        if (hasAuthority)
        {
            Local = this;
        }
    }
Esempio n. 4
0
        public void DeleteActor(Actor actor)
        {
            if (Actors.Contains(actor))
            {
                Actors.Remove(actor);
            }

            foreach (var film in actor.Films)
            {
                film.Actors.Remove(actor);
                DataHelper.FilmToActorConnections[film.ID].Remove(actor.ID);
            }
        }
Esempio n. 5
0
        private void SubmitCommandExecute()
        {
            if (Actors.Contains(Actor))
            {
                int insertPos = Actors.IndexOf(Actor);
                Actors.Remove(Actor);
                Actors.Insert(insertPos, _editedActor);
                Actor = _editedActor;
                return;
            }

            Actors.Add(_editedActor);
            Actor = _editedActor;
        }
        public async Task <IActionResult> OnGetAsync(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            // Retrieve the first movie with ID equal to received id. Include the appeareances of actors in that
            // movie. Then include the actors in the appearences of the movie.
            Movie = await _context.Movies
                    .Where(m => m.ID == id)
                    .Include(l => l.Location)
                    .Include(c => c.Appeareances)
                    .ThenInclude(a => a.Actor)
                    .AsNoTracking()
                    .FirstOrDefaultAsync();

            if (Movie == null)
            {
                return(NotFound());
            }

            // Populate the list of actors in the viewmodel with the actors of the movie.
            this.Actors = Movie.Appeareances
                          .Select(a => a.Actor);

            string nameFilter = "";

            if (this.SearchString != null)
            {
                nameFilter = this.SearchString.ToUpper();
            }

            // Populate the list of all other actors with all actors not included in the movie's actors and
            // included in the search filter.
            this.AllActors = await _context.Actors
                             .Where(a => !Actors.Contains(a))
                             .Where(a => !string.IsNullOrEmpty(nameFilter) ? a.Name.ToUpper().Contains(nameFilter) : true)
                             .ToListAsync();

            return(Page());
        }
Esempio n. 7
0
        public new void Add(Movie item)
        {
            if (!String.IsNullOrEmpty(item.Category) && !Categories.Contains(item.Category))
            {
                Categories.Add(item.Category);
            }

            if (!String.IsNullOrEmpty(item.Country) && !Countries.Contains(item.Country))
            {
                Countries.Add(item.Country);
            }

            if (item.Actors != null)
            {
                foreach (string actor in item.Actors)
                {
                    if (!Actors.Contains(actor.Trim()))
                    {
                        Actors.Add(actor.Trim());
                    }
                }
            }

            if (item.ID == 0 || usedIds.Contains(item.ID))
            {
                item.ID = idCounter;
                idCounter++;
            }
            else
            {
                usedIds.Add(item.ID);
                idCounter = item.ID + 1;
            }

            base.Add(item);
        }