Exemple #1
0
        public async Task <IActionResult> Get(int skip = 0, int limit = 0)
        {
            try
            {
                List <Movie> movies = await _moviesManager.GetMovies(skip, limit);

                return(Ok(movies));
            }
            catch (CouldNotPerformOperationException ex)
            {
                return(BadRequest(ex));
            }
        }
        public async Task <List <MovieScreeningList> > GetDayRepertoir(DateTime date)
        {
            try
            {
                List <MovieScreeningList> repertoir = new List <MovieScreeningList>();

                List <Screening> screenings = await _screeningsManager.GetDayScrenings(date);

                List <Movie> movies = await _moviesManager.GetMovies();

                if (screenings.Any())
                {
                    foreach (Screening screening in screenings)
                    {
                        MovieScreeningList movieScreeningList = repertoir.FirstOrDefault(obj => obj.Movie.Id == screening.MovieId && obj.AudioType == screening.AudioType && obj.VideoType == screening.VideoType);

                        if (movieScreeningList != null)
                        {
                            movieScreeningList.Screenings.Add(screening);
                        }
                        else
                        {
                            movieScreeningList = new MovieScreeningList()
                            {
                                Movie      = movies.FirstOrDefault(m => m.Id == screening.MovieId),
                                AudioType  = screening.AudioType,
                                VideoType  = screening.VideoType,
                                Screenings = new List <Screening>()
                                {
                                    screening
                                }
                            };

                            repertoir.Add(movieScreeningList);
                        }
                    }
                }

                return(repertoir);
            }
            catch (Exception ex)
            {
                return(null);
            }
        }