// Search All The Flights For Current Customer. public IList <Flight> GetAllMyFlights(LoginToken <Customer> token) { IList <Flight> flightsByCustomer = null; if (UserIsValid(token)) { flightsByCustomer = _flightDAO.GetFlightsByCustomer(token.User); } return(flightsByCustomer); }
public void GetFlightsByCustomer() { countryDAO.Add(new Country("Israel")); Country israel = countryDAO.GetCountryByName("Israel"); airlineDAO.Add(new AirlineCompany("ELAL", "ELALUSERNAME", "PASSWORD", israel.ID)); AirlineCompany elal = airlineDAO.GetAirlineByName("ELAL"); flightDAO.Add(new Flight(elal.ID, israel.ID, israel.ID, new DateTime((DateTime.Now.Year + 2), 12, 5, 14, 00, 00), new DateTime((DateTime.Now.Year + 2), 12, 7, 14, 00, 00), 50, FlightStatus.NotDeparted)); flightDAO.Add(new Flight(elal.ID, israel.ID, israel.ID, new DateTime((DateTime.Now.Year + 2), 12, 5, 14, 00, 00), new DateTime((DateTime.Now.Year + 2), 12, 7, 14, 00, 00), 20, FlightStatus.NotDeparted)); customerDAO.Add(new Customer("FIRSTNAME", "LAST NAME", "USERNAME", "PASSWORD", "ADDRESS", "PHONENUMBE", "CARDNUMBER")); Customer customerTest = customerDAO.GetAll()[0]; ticketDAO.Add(new Ticket(flightDAO.GetAll()[0].ID, customerTest.ID)); ticketDAO.Add(new Ticket(flightDAO.GetAll()[1].ID, customerTest.ID)); List <Flight> customerFlights = (List <Flight>)flightDAO.GetFlightsByCustomer(customerTest); Assert.AreEqual(2, customerFlights.Count); }