Beispiel #1
0
        public async Task UpdateFlightSeats(TicketBought @event, ICorrelationContext context)
        {
            var flight = await _flightsRepository.GetAsync(@event.FlightId);

            flight.DecreaseAvailableSeats(@event.AvailableSeats);
            await _flightsRepository.UpdateAsync(flight);
        }
Beispiel #2
0
        public async Task HandleAsync(EndFlight command, ICorrelationContext context)
        {
            var flight = await _flightsRepository.GetAsync(command.Id);

            flight.SetFlightStatus(FlightStatus.Finished);

            await _flightsRepository.UpdateAsync(flight);

            await _busPublisher.PublishAsync(new FlightEnded(flight.PlaneId), context);
        }
        public async Task HandleAsync(BookFlight command, ICorrelationContext context)
        {
            var flight = await _flightsRepository.GetAsync(command.FlightId);

            if (flight is null)
            {
                throw new BeComfyException("cannot_book_flight", $"Flight with id: {command.FlightId} does not exist");
            }

            // TODO : Finish process
        }
        public async Task <FlightDto> HandleAsync(GetFlight query)
        {
            var flight = await _flightsRepository.GetAsync(query.Id);

            return(flight == null
                ? null
                : new FlightDto
            {
                Id = flight.Id,
                StartAirport = flight.StartAirport,
                AvailableSeats = flight.AvailableSeats,
                TransferAirports = flight.TransferAirports,
                EndAirport = flight.EndAirport,
                FlightStatus = flight.FlightStatus,
                FlightType = flight.FlightType,
                FlightDate = flight.FlightDate,
                ReturnDate = flight.ReturnDate,
            });
        }