Пример #1
0
        public IActionResult CreateCinema(CinemaCreateViewModel model)
        {
            List <Room> newRooms = new();

            Cinema cinema = new();

            cinema.Name      = model.Name;
            cinema.TimeClose = model.TimeClose;
            cinema.Adress    = model.Adress;
            Room room = new();

            for (int i = 0; i < model.RoomCount; i++)
            {
                room.Name   = $"{i}:{cinema.Name}";
                room.Cinema = cinema;

                _sqlRoomService.CreateRoom(room);

                newRooms.Add(room);

                room = new();
            }

            cinema.Rooms = newRooms;

            _sqlCinemaService.CreateCinema(cinema);

            return(RedirectToAction(nameof(CreateCinema)));
        }
Пример #2
0
        public void CreateRoom_ShouldPersist()
        {
            //Arrange
            List <Room> rooms = new();

            Room room = new();

            room.Cinema    = new();
            room.CinemaId  = 1;
            room.MovieRoom = new List <MovieRoom>();
            room.Name      = "Hello";

            Seat seat = new();

            seat.ColumnId = ColumnType.k;
            seat.RowId    = RowType.A;
            seat.RoomId   = room.Id;

            rooms.Add(room);

            Cinema cinema = new();

            cinema.Name      = "w";
            cinema.Rooms     = rooms;
            cinema.TimeClose = "w";
            cinema.City      = CityType.California;

            _sqlCinemaService.CreateCinema(cinema);

            _dbContext.SaveChanges();

            //Act
            _sqlRoomService.CreateRoom(room);

            //Assert
            Room roomDb = _dbContext.Room.FirstOrDefault(r => r.Id == room.Id);

            Assert.IsNotNull(roomDb);
            Assert.AreEqual(room.Id, roomDb.Id);
            Assert.AreEqual(room.Name, roomDb.Name);
            Assert.AreEqual(room.Seats, roomDb.Seats);
            Assert.AreEqual(room.CinemaId, roomDb.CinemaId);
        }
Пример #3
0
        public void RoomDetails_ShouldBeValid()
        {
            //Arrange
            List <Room> rooms = new();

            Room room = new();

            room.Cinema    = new();
            room.CinemaId  = 1;
            room.MovieRoom = new List <MovieRoom>();
            room.Name      = "Hello";

            Seat seat = new();

            seat.ColumnId = ColumnType.k;
            seat.RowId    = RowType.A;
            seat.RoomId   = room.Id;

            rooms.Add(room);

            Cinema cinema = new();

            cinema.Name      = "w";
            cinema.Rooms     = rooms;
            cinema.TimeClose = "w";
            cinema.City      = CityType.California;

            _sqlCinemaService.CreateCinema(cinema);

            _dbContext.SaveChanges();

            //Act
            _sqlRoomService.CreateRoom(room);

            //Assert
            ViewResult result = _roomController.RoomDetails(room.Id) as ViewResult;
            Room       model  = result.Model as Room;

            Assert.IsNotNull(model);
            Assert.IsInstanceOfType(result, typeof(ViewResult));
            Assert.IsInstanceOfType(model, typeof(Room));
        }