public void CreateFlight(string aName, string orig, string dest, int year, int month, int day, string id) { Airline airline = _airlineRepository.Retreive(aName); Airport origin = _airportRepository.Retreive(orig); Airport destination = _airportRepository.Retreive(dest); try { Flight flight = new Flight(airline, origin, destination, year, month, day, id); airline.Flights.AddNewFlight(flight); } catch (Exception e) { Console.WriteLine($"{e.Message}- {airline.Name}"); } }
public Flight(Airline airline, Airport originAirport, Airport destinationAirport, int year, int month, int day, string id) { if (airline == null) { throw new Exception(ExceptionHelper.NonExistentAirline); } if (originAirport == null) { throw new Exception(ExceptionHelper.NonExistentAirport); } if (destinationAirport == null) { throw new Exception(ExceptionHelper.NonExistentAirport); } this.FlightId = id; this.Airline = airline; this.Origin = originAirport; this.Destination = destinationAirport; this.FlightDate = new DateTime(year, month, day); }
public void CreateSection(string aName, string flightId, int rows, int cols, SeatClass s) { try { Airline airline = _airlineRepository.Retreive(aName); Flight flight = airline.Flights.Retreive(flightId); FlightSection section = new FlightSection(s, rows, cols); if (airline == null) { throw new Exception(ExceptionHelper.NonExistentAirline); } if (flight == null) { throw new Exception(ExceptionHelper.FlightNotFound); } flight.AddFlightSection(section); } catch (Exception e) { Console.WriteLine($"{e.Message} - {aName}"); } }
public void CreateFlight(string aName, string orig, string dest, int year, int month, int day, string id) { try { Airline airline = _airlineRepository.Retreive(aName); Airport origin = _airportRepository.Retreive(orig); Airport destination = _airportRepository.Retreive(dest); if (airline == null) { throw new Exception(ExceptionHelper.NonExistentAirline); } if (origin == null) { throw new Exception(ExceptionHelper.NonExistentAirport); } if (destination == null) { throw new Exception(ExceptionHelper.NonExistentAirport); } Flight flight = new Flight() { AirlineId = airline.AirlineId, OrgAirportId = origin.AirportId, DestAirportId = destination.AirportId, Date = new DateTime(year, month, day), FlightName = id }; _flightRepository.AddNewFlight(flight); Console.WriteLine("Succesfully inserted flight"); } catch (Exception e) { Console.WriteLine($"{e.Message}"); } }
public void BookSeat(string aName, string flightId, SeatClass s, int row, char col) { try { Airline airline = _airlineRepository.Retreive(aName); Flight flight = airline.Flights.Retreive(flightId); if (airline == null) { throw new Exception(ExceptionHelper.NonExistentAirline); } if (flight == null) { throw new Exception(ExceptionHelper.NonExistentFlight); } if (!flight.BookSeat(s, row, col)) { throw new Exception(ExceptionHelper.SeatAlreadyBooked); } } catch (Exception e) { Console.WriteLine($"{e.Message}- Airline: {aName} : {flightId} Seat: {row} {col}"); } }