public async Task CheckIfGetAllMovieProjectionsAsQueryeableWorksCorrectly()
        {
            this.SeedDatabase();
            await this.SeedMovieProjections();

            var secondMovie = new Movie
            {
                Name           = "Anabel",
                DateOfRelease  = DateTime.UtcNow.AddDays(3),
                Resolution     = "HD",
                Rating         = 7.80m,
                Description    = "Test description here",
                Language       = "English",
                CinemaCategory = CinemaCategory.B,
                TrailerPath    = "test trailer path",
                CoverPath      = "test cover path",
                WallpaperPath  = "test wallpaper path",
                IMDBLink       = "test imdb link",
                Length         = 120,
                DirectorId     = 1,
            };

            await this.moviesRepository.AddAsync(secondMovie);

            await this.moviesRepository.SaveChangesAsync();

            var secondMovieProjection = new MovieProjection
            {
                Date     = DateTime.UtcNow,
                MovieId  = 2,
                HallId   = 1,
                CinemaId = 1,
            };

            await this.movieProjectionsRepository.AddAsync(secondMovieProjection);

            await this.movieProjectionsRepository.SaveChangesAsync();

            var result = this.movieProjectionsService.GetAllMovieProjectionsAsQueryeable <MovieProjectionDetailsViewModel>();

            var count = result.Count();

            Assert.Equal(2, count);
            Assert.Equal("Bulgaria Mall", result.First().Cinema.Name);
        }
        private void InitializeFields()
        {
            this.firstHall = new Hall
            {
                Category = HallCategory.Large,
                Capacity = 100,
            };

            this.firstCinema = new Cinema
            {
                Name    = "Bulgaria Mall",
                Address = "Sofia, bul. Stamboliiski",
            };

            this.firstDirector = new Director
            {
                FirstName = "Steven",
                LastName  = "Spielberg",
            };

            this.firstMovie = new Movie
            {
                Name           = "Titanic",
                DateOfRelease  = DateTime.UtcNow,
                Resolution     = "HD",
                Rating         = 7.80m,
                Description    = "Test description here",
                Language       = "English",
                CinemaCategory = CinemaCategory.B,
                TrailerPath    = "test trailer path",
                CoverPath      = "test cover path",
                WallpaperPath  = "test wallpaper path",
                IMDBLink       = "test imdb link",
                Length         = 120,
                DirectorId     = 1,
            };

            this.firstMovieProjection = new MovieProjection
            {
                Date     = DateTime.UtcNow,
                MovieId  = 1,
                HallId   = 1,
                CinemaId = 1,
            };
        }
示例#3
0
        public async Task <MovieProjectionDetailsViewModel> CreateAsync(MovieProjectionCreateInputModel model)
        {
            var movie = await this.moviesRepository
                        .All()
                        .FirstOrDefaultAsync(m => m.Id == model.MovieId);

            if (movie == null)
            {
                throw new NullReferenceException(
                          string.Format(ExceptionMessages.MovieNotFound, model.MovieId));
            }

            var hall = await this.hallsRepository
                       .All()
                       .FirstOrDefaultAsync(h => h.Id == model.HallId);

            if (hall == null)
            {
                throw new NullReferenceException(
                          string.Format(ExceptionMessages.HallNotFound, model.HallId));
            }

            var cinema = await this.cinemasRepository
                         .All()
                         .FirstOrDefaultAsync(c => c.Id == model.CinemaId);

            if (cinema == null)
            {
                throw new NullReferenceException(
                          string.Format(ExceptionMessages.CinemaNotFound, model.CinemaId));
            }

            var movieProjection = new MovieProjection
            {
                Date     = model.Date,
                Movie    = movie,
                MovieId  = model.MovieId,
                Hall     = hall,
                HallId   = model.HallId,
                Cinema   = cinema,
                CinemaId = model.CinemaId,
            };

            bool doesMovieProjectionExist = await this.movieProjectionsRepository
                                            .All()
                                            .AnyAsync(x => x.MovieId == movieProjection.MovieId && x.HallId == movieProjection.HallId);

            if (doesMovieProjectionExist)
            {
                throw new ArgumentException(
                          string.Format(ExceptionMessages.MovieProjectionAlreadyExists, movieProjection.MovieId, movieProjection.HallId));
            }

            await this.movieProjectionsRepository.AddAsync(movieProjection);

            await this.movieProjectionsRepository.SaveChangesAsync();

            var viewModel = await this.GetViewModelByIdAsync <MovieProjectionDetailsViewModel>(movieProjection.Id);

            return(viewModel);
        }
        private void InitializeFields()
        {
            this.firstTicket = new Ticket
            {
                Row        = 1,
                Seat       = 1,
                Price      = 10,
                TimeSlot   = TimeSlot.Afternoon,
                TicketType = TicketType.Regular,
                Quantity   = 1,
            };

            this.firstDirector = new Director
            {
                FirstName = "Peter",
                LastName  = "Kirilov",
            };

            this.firstMovie = new Movie
            {
                Name           = "Titanic",
                DateOfRelease  = DateTime.UtcNow,
                Resolution     = "HD",
                Rating         = 7.80m,
                Description    = "Test description here",
                Language       = "English",
                CinemaCategory = CinemaCategory.B,
                TrailerPath    = "test trailer path",
                CoverPath      = "test cover path",
                WallpaperPath  = "test wallpaper path",
                IMDBLink       = "test imdb link",
                Length         = 120,
                DirectorId     = 1,
            };

            this.firstHall = new Hall
            {
                Category = HallCategory.Small,
                Capacity = 20,
            };

            this.firstCinema = new Cinema
            {
                Name    = "Bulgaria Mall",
                Address = "Sofia bul.Stamboliiski",
            };

            this.firstMovieProjection = new MovieProjection
            {
                Date     = DateTime.ParseExact("30/09/2020 14:30:00", "dd/MM/yyyy HH:mm:ss", CultureInfo.InvariantCulture),
                MovieId  = 1,
                HallId   = 1,
                CinemaId = 1,
            };

            this.firstSeat = new Seat
            {
                Number      = 1,
                RowNumber   = 1,
                HallId      = 1,
                Category    = SeatCategory.Normal,
                IsAvailable = true,
                IsSold      = false,
            };
        }