コード例 #1
0
        public async Task <FastFlightResponse> Add(int airlineId, int flightId, int row, int column, double discountPercentage)
        {
            var airline = await airlineRepo.GetAirline(airlineId);

            if (airline != null)
            {
                foreach (var flight in airline.Flights)
                {
                    if (flight.Id == flightId)
                    {
                        if (!flightRepo.IsSeatOkForChange(row, column, airline, flight, true, true))
                        {
                            var fastFlight = new FastFlight();
                            fastFlight.Flight             = flight;
                            fastFlight.DiscountPercentage = discountPercentage;
                            fastFlight.Column             = column;
                            fastFlight.Row     = row;
                            fastFlight.Airline = airline;
                            airline.FastFlights.Add(fastFlight);
                            return(new FastFlightResponse(fastFlight));
                        }
                        return(new FastFlightResponse("Seat is not available."));
                    }
                }
                return(new FastFlightResponse("Flight with given id does not exist."));
            }
            else
            {
                return(new FastFlightResponse("Airline with given id does not exist."));
            }
        }
コード例 #2
0
 public async Task <BookingAppBackend.Model.Airlines.Airline> GetAirline(int id)
 {
     return(await repo.GetAirline(id));
 }