コード例 #1
0
        public async Task <IEnumerable <ProjectionDomainModel> > GetAllAsyncForSpecificMovie(Guid id)
        {
            var data = await _projectionsRepository.GetAllFromOneMovie(id);

            List <ProjectionDomainModel> result = new List <ProjectionDomainModel>();

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

            ProjectionDomainModel model;

            foreach (var item in data)
            {
                model = new ProjectionDomainModel
                {
                    Id                   = item.Id,
                    MovieId              = item.MovieId,
                    AuditoriumId         = item.AuditoriumId,
                    ProjectionTimeString = item.DateTime.ToString("hh:mm tt"),
                    MovieTitle           = item.Movie.Title,
                    AuditoriumName       = item.Auditorium.Name
                };
                List <Seat> listaSeat = new List <Seat>();
                var         seatsForThisAuditorium = await _seatsRepository.GetAllOfSpecificAuditoriumForProjection(model.AuditoriumId);

                var row        = 0;
                var seatPerRow = 0;
                foreach (var seatInAuditorium in seatsForThisAuditorium)
                {
                    listaSeat.Add(seatInAuditorium);
                }
                foreach (var seat in listaSeat)
                {
                    row        = seat.Row;
                    seatPerRow = seat.Number;
                }
                model.NumOFRows        = row;
                model.NumOFSeatsPerRow = seatPerRow;
                result.Add(model);
            }

            return(result);
        }