Esempio n. 1
0
 public void Edit(CastAndCrew castAndCrew)
 {
     _repo.Update(castAndCrew);
     _repo.Save();
 }
Esempio n. 2
0
        //For Edit and Create Actors (POST)
        private void CreateOfUpdateActorsInMovie(string[] selectedActors, MovieViewModel movieViewModel)
        {
            if (selectedActors == null)
            {
                movieViewModel.CastAndCrews = new List<CastAndCrew>();
                return;
            }

            if (movieViewModel.CastAndCrews == null)
            {
                movieViewModel.CastAndCrews = new List<CastAndCrew>();
            }

            var selectedActorsHs = new HashSet<string>(selectedActors);
            var actorsInMovie = new HashSet<Guid>(movieViewModel.CastAndCrews.Select(c => c.PeopleId));
            foreach (var actor in _peopleService.GetAll())
            {
                var addActor = new CastAndCrew
                {
                    MovieId = movieViewModel.Id,
                    PeopleId = actor.Id,
                    CareerId = _careerService.GetCareerByTitle("Actor").Id
                };
                if (selectedActorsHs.Contains(actor.Id.ToString()))
                {
                    if (!actorsInMovie.Contains(actor.Id))
                    {
                        movieViewModel.CastAndCrews.Add(addActor);
                    }
                }
                else
                {
                    if (actorsInMovie.Contains(actor.Id))
                    {
                        movieViewModel.CastAndCrews.Remove(addActor);
                    }
                }
            } 
        }
Esempio n. 3
0
 public void AddCastAndCrew(CastAndCrew castAndCrew)
 {
     _repo.Insert(castAndCrew);
     _repo.Save();
 }