public void getSearchedTrip(IBrowseTripsForm form) { bool destFound = false; bool depFound = false; DateTime depTime = new DateTime(); DateTime destTime = new DateTime(); List<Trip> trips = TripRepository.GetInstance().GetNotFullOnes(); List<Match> matchList = new List<Match>(); string departure = form.getSelectedCityDeparture().ToLower(); departure += "," + form.getSelectedCountryDeparture().ToLower(); string destination = form.getSelectedCityDestination().ToLower(); destination += "," + form.getSelectedCountryDest().ToLower(); foreach (Trip t in trips) { if (t.isDone == false) { foreach (TripStops st in t.Stops) { string tmp1 = st.City.Name.ToLower(); tmp1 += "," + st.City.Country.ToLower(); if (tmp1 == departure) { depFound = true; depTime = st.TripDate; } if (tmp1 == destination) { destFound = true; destTime = st.TripDate; } } if (destFound == true && depFound == true && destTime > depTime) { matchList.Add(new Match(depTime, destTime, t)); } } } foreach (Match m in matchList) { string id = m.t.ID.ToString(); string depart = m.departure.ToString(); string arrival = m.arrival.ToString(); string name = m.t.TripOwner.Name +" "+ m.t.TripOwner.Surname; string phone = m.t.TripOwner.ContactPhone; string mail = m.t.TripOwner.ContactEMail; form.setDisplayItem(id, depart, arrival, name, phone, mail); } }