Exemplo n.º 1
0
        public async Task AddAsync(AddHallInputModel inputModel)
        {
            var projectionType = Enum.Parse(typeof(ProjectionType), inputModel.ProjectionType);
            var seats          = new List <Seat>();

            var hall = new Hall
            {
                ProjectionType = (ProjectionType)projectionType,
                Seats          = seats,
            };

            for (int i = 0; i < inputModel.Seats; i++)
            {
                var seat = new Seat
                {
                    HallId = hall.Id,
                };

                seats.Add(seat);
            }

            await this.hallsRepository.AddAsync(hall);

            await this.hallsRepository.SaveChangesAsync();
        }
Exemplo n.º 2
0
        public async Task <IActionResult> AddAsync(AddHallInputModel inputModel)
        {
            if (!this.ModelState.IsValid)
            {
                return(this.View(inputModel));
            }

            await this.hallsService.AddAsync(inputModel);

            return(this.Redirect("/"));
        }
Exemplo n.º 3
0
        public HallsServiceTests()
        {
            this.hall = new AddHallInputModel
            {
                ProjectionType = "TwoD",
                Seats          = 50,
            };

            AutoMapperConfig.RegisterMappings(typeof(TestHallViewModel).Assembly);
            this.options = new DbContextOptionsBuilder <ApplicationDbContext>()
                           .UseInMemoryDatabase(Guid.NewGuid().ToString());
        }
Exemplo n.º 4
0
        public async Task GetByIdShouldReturnCorrectData()
        {
            var repository = new EfDeletableEntityRepository <Hall>(new ApplicationDbContext(this.options.Options));
            var service    = new HallsService(repository);

            var diffHall = new AddHallInputModel
            {
                ProjectionType = "FourDx",
                Seats          = 100,
            };

            await service.AddAsync(this.hall);

            await service.AddAsync(diffHall);

            var result = service.GetById <TestHallViewModel>(2);

            Assert.Equal(ProjectionType.FourDx, result.ProjectionType);
        }