Exemplo n.º 1
0
        public void CreateHall(HallDTO hallDTO)
        {
            if (hallDTO.NumberOfSeats != hallDTO.NumberOfRows * hallDTO.NumberOfSeatsInRow)
            {
                throw new IncorrectDataException("Incorrect number of seats");
            }
            Hall        hall  = _mapper.Map <Hall>(hallDTO);
            List <Seat> seats = new List <Seat>();

            for (int i = 1; i <= hall.NumberOfRows; i++)
            {
                for (int k = 1; k <= hall.NumberOfSeatsInRow; k++)
                {
                    Seat seat = new Seat
                    {
                        HallId     = hall.Id,
                        Hall       = hall,
                        SeatNumber = k,
                        RowNumber  = i
                    };
                    seats.Add(seat);
                    _unit.SeatRepository.Create(seat);
                }
            }
            hall.Seats = seats;
            _unit.HallRepository.Create(hall);
            _unit.Save();
        }
Exemplo n.º 2
0
        public IEnumerable <HallDTO> GetAllHalls()
        {
            IEnumerable <Hall> halls    = _unit.HallRepository.GetAll();
            List <HallDTO>     HallsDTO = new List <HallDTO>();

            foreach (Hall p in halls)
            {
                HallDTO perf = _mapper.Map <HallDTO>(p);
                HallsDTO.Add(perf);
            }
            return(HallsDTO);
        }