public async Task <Train> GetTrainDuVoyageAsync(IdVoyage idVoyage)
        {
            var reservations =
                await _dbContext.Set <DbReservation>()
                .Include(r => r.Passagers)
                .Where(r => r.IdVoyage == (int)idVoyage)
                .ToListAsync();

            var voyage = await _voyageUseCase.GetVoyageAsync((int)idVoyage);

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

            return(new Train(
                       idVoyage,
                       voyage.Train.Voitures
                       .Select(v =>
                               new Voiture(
                                   new NumeroVoiture(v.Numero),
                                   v.Capacite,
                                   GetNbReservations(reservations, v.Numero)))
                       .ToList()));
        }
Ejemplo n.º 2
0
        public async Task <IActionResult> GetAsync(int id)
        {
            var voyage = await _useCase.GetVoyageAsync(id);

            return(Ok(voyage));
        }