Ejemplo n.º 1
0
        public IActionResult AddMovieToRoom(MovieToRoomViewModel model)
        {
            string selectedMovie = model.MovieName;
            string selectedRoom  = model.RoomName;

            Movie movie = _sqlMovieService.GetMovieByName(selectedMovie);
            Room  room  = _sqlRoomService.GetRoomByName(selectedRoom);

            MovieRoom movieRoom = new();

            movieRoom.Movie   = movie;
            movieRoom.Room    = room;
            movieRoom.MovieId = movie.Id;
            movieRoom.RoomId  = room.Id;
            movieRoom.AirTime = model.AirTime;

            _sqlMovieRoomService.AddMovieToRoom(movieRoom);

            return(RedirectToAction(nameof(Index)));
        }
Ejemplo n.º 2
0
        public void GetRoomByName_ShouldWork()
        {
            //Arrange
            Room room = new()
            {
                Name      = "wwwe",
                Cinema    = new Cinema(),
                Seats     = new List <Seat>(),
                CinemaId  = 1,
                MovieRoom = new List <MovieRoom>()
            };

            //Act
            _dbContext.Room.Add(room);

            _dbContext.SaveChanges();

            //Assert
            Room roomDb = _sqlRoomService.GetRoomByName(room.Name);

            Assert.IsNotNull(roomDb);
            Assert.AreEqual(room, roomDb);
        }