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()); }
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)); } }
public ActionResult <List <Hall> > CreateHall(Hall hall) { return(Created("", hallService.CreateHall(hall))); }