Exemple #1
0
        public bool UpdateMovie(UpdateMovieDTO updateMovieDTO)
        {
            Movie movie = movieRepository.GetByID(updateMovieDTO.Id);

            movie.Title       = updateMovieDTO.Title;
            movie.Category    = Enum.Parse <Category>(updateMovieDTO.Category);
            movie.Description = updateMovieDTO.Description;
            movie.Duration    = updateMovieDTO.Duration;
            movie.PosterUrl   = updateMovieDTO.PosterUrl;

            movie.ScreeningTimes.Clear();


            foreach (var screening in updateMovieDTO.ScreeningTimes)
            {
                ScreeningTime screeningTime = ScreeningTimeBuilder.Init(hallRepository)
                                              .SetDate(screening.Date)
                                              .SetSeatsFromHall(screening.HallId)
                                              .Build();

                movie.ScreeningTimes.Add(screeningTime);
            }

            return(movieRepository.SaveChanges() > 0);
        }
Exemple #2
0
        public bool CreateMovie(CreateMovieDTO createMovie)
        {
            Movie movie = new Movie
            {
                Title          = createMovie.Title,
                Category       = Enum.Parse <Category>(createMovie.Category),
                Description    = createMovie.Description,
                Duration       = createMovie.Duration,
                PosterUrl      = createMovie.PosterUrl,
                ScreeningTimes = new List <ScreeningTime>()
            };

            foreach (var screening in createMovie.ScreeningTimes)
            {
                ScreeningTime screeningTime = ScreeningTimeBuilder.Init(hallRepository)
                                              .SetDate(screening.Date)
                                              .SetSeatsFromHall(screening.HallId)
                                              .Build();

                movie.ScreeningTimes.Add(screeningTime);
            }

            movieRepository.Insert(movie);
            return(movieRepository.SaveChanges() > 0);
        }