Example #1
0
        public void ShouldCreateAndSaveHallWithSeatsInCorrectOrder()
        {
            //Arrange
            Hall hall = CreateHall();

            //Act
            hallService.CreateHall(hall);

            //Assert
            IEnumerable <Hall> halls = hallService.GetAll();
            List <Seat>        seats = halls.First().Rows.First().Seats.ToList();

            Assert.NotEmpty(halls);
            Assert.Single(halls);
            Assert.Equal("asd", halls.First().HallName);
            Assert.Equal(SeatStatus.Free, seats[0].Status);
            Assert.Equal(SeatStatus.Excluded, seats[1].Status);
            Assert.Equal(SeatStatus.Free, seats[2].Status);
            Assert.Equal(hall.Rows[0].Seats.Count, applicationDbContext.Seats.Count());
        }
Example #2
0
 public IHttpActionResult CreateHall(HallModel hallModel)
 {
     if (!ModelState.IsValid)
     {
         return(BadRequest(ModelState));
     }
     try
     {
         HallDTO hall = _mapper.Map <HallDTO>(hallModel);
         _hallService.CreateHall(hall);
         return(Ok("Hall was created"));
     }
     catch (Exception ex)
     {
         return(InternalServerError(ex));
     }
 }
Example #3
0
 public ActionResult <List <Hall> > CreateHall(Hall hall)
 {
     return(Created("", hallService.CreateHall(hall)));
 }