public async Task <IEnumerable <MovieTag> > DeleteByMovieId(Guid movieId)
        {
            IEnumerable <MovieTag> existing = _cinemaContext.MovieTags.Where(x => x.MovieId == movieId);
            List <MovieTag>        result   = new List <MovieTag>();

            foreach (MovieTag movieTag in existing)
            {
                var data = _cinemaContext.Remove(movieTag);
                result.Add(data.Entity);
            }

            return(result);
        }
Beispiel #2
0
        public async Task <IEnumerable <Projection> > DeleteByAuditoriumId(int auditoriumId)
        {
            IEnumerable <Projection> projectionList = _cinemaContext.Projections.Where(x => x.AuditoriumId == auditoriumId);
            List <Projection>        result         = new List <Projection>();

            foreach (Projection projection in projectionList)
            {
                var data = _cinemaContext.Remove(projection);
                result.Add(data.Entity);
            }

            return(result);
        }
        private void UpdateAppearanceMovies(string[] selectedMovies, Actor actorToUpdate)
        {
            if (selectedMovies == null)
            {
                actorToUpdate.AppearanceMovies = new List <AppearanceMovie>();
                return;
            }
            var selectedMoviesHS = new HashSet <string>(selectedMovies);
            var appearanceMovies = new HashSet <int>
                                       (actorToUpdate.AppearanceMovies.Select(c => c.Movie.MovieID));

            foreach (var movie in _context.Movies)
            {
                if (selectedMoviesHS.Contains(movie.MovieID.ToString()))
                {
                    if (!appearanceMovies.Contains(movie.MovieID))
                    {
                        actorToUpdate.AppearanceMovies.Add(new AppearanceMovie {
                            ActorID = actorToUpdate.ActorID, MovieID = movie.MovieID
                        });
                    }
                }
                else
                {
                    if (appearanceMovies.Contains(movie.MovieID))
                    {
                        AppearanceMovie movieToRemove = actorToUpdate.AppearanceMovies.FirstOrDefault(i => i.MovieID == movie.MovieID);
                        _context.Remove(movieToRemove);
                    }
                }
            }
        }
        public async Task <IEnumerable <Seat> > DeleteByAuditoriumId(int auditoriumId)
        {
            IEnumerable <Seat> seatList = _cinemaContext.Seats.Where(x => x.AuditoriumId == auditoriumId);
            List <Seat>        result   = new List <Seat>();

            foreach (Seat seat in seatList)
            {
                var data = _cinemaContext.Remove(seat);
                result.Add(data.Entity);
            }

            return(result);
        }
        public async Task <IEnumerable <Auditorium> > DeleteByCinemaId(int cinemaId)
        {
            IEnumerable <Auditorium> existing = _cinemaContext.Auditoriums.Where(x => x.CinemaId == cinemaId);
            List <Auditorium>        result   = new List <Auditorium>();

            foreach (Auditorium auditorium in existing)
            {
                var data = _cinemaContext.Remove(auditorium);
                result.Add(data.Entity);
            }

            return(result);
        }