Esempio n. 1
0
        public async Task <IEnumerable <SeatDomainModel> > GetAllSeatsForProjection(Guid id)
        {
            var allSeatsForProjection = await _seatsRepository.GetAllOfSpecificProjection(id);

            var reservedSeatsForThisProjection = _ticketRepository.GetAllForSpecificProjection(id);


            if (allSeatsForProjection == null)
            {
                return(null);
            }

            List <SeatDomainModel> result = new List <SeatDomainModel>();
            SeatDomainModel        model;

            foreach (var seat in allSeatsForProjection)
            {
                model = new SeatDomainModel
                {
                    AuditoriumId = seat.AuditoriumId,
                    Id           = seat.Id,
                    Number       = seat.Number,
                    Row          = seat.Row
                };

                foreach (var reservedSeat in reservedSeatsForThisProjection)
                {
                    if (seat.Id == reservedSeat.SeatId)
                    {
                        model.Reserved = true;
                    }
                }
                result.Add(model);
            }

            return(result);
        }