Exemple #1
0
        public IEnumerable <SeanceView> GetSeances(SeanceFilter filter)
        {
            IQueryable <Seance> seances = _db.Seances
                                          .Include(s => s.Movie)
                                          .Include(s => s.Hall)
                                          .Include(s => s.Hall.Cinema)
                                          .AsNoTracking();

            if (filter.MovieId != null)
            {
                seances = seances.Where(s => s.MovieId == filter.MovieId);
            }
            if (filter.StartDate != null)
            {
                seances = seances.Where(s => filter.StartDate < s.ShowDate);
            }
            if (filter.EndDate != null)
            {
                seances = seances.Where(s => s.ShowDate < filter.EndDate);
            }

            return(seances.Where(s => !s.IsDeleted)
                   .Select(sc => new SeanceView
            {
                Id = sc.Id,
                ShowDate = sc.ShowDate,
                ShowTime = sc.ShowTime,
                Cinema = new CinemaView
                {
                    Id = sc.Hall.Cinema.Id,
                    Title = sc.Hall.Cinema.Title,
                    City = sc.Hall.Cinema.City
                },
                Hall = new HallView
                {
                    Id = sc.HallId,
                    Name = sc.Hall.Name
                },
                Movie = new MovieView
                {
                    Id = sc.MovieId,
                    Title = sc.Movie.Title
                }
            }));
        }
Exemple #2
0
        public IActionResult GetSeances([FromQuery] SeanceFilter filter)
        {
            var seances = _seanceService.GetSeances(filter);

            return(Ok(new GetResponse <IEnumerable <SeanceView> >(seances)));
        }