public async Task <IEnumerable <ITrip> > FindTripsAsync(string from, string to, DateTime departureDate) { var fromCode = availableStations.Select(i => i).FirstOrDefault(i => i.Location == from.ToUpper())?.Code; var toCode = availableStations.Select(i => i).FirstOrDefault(i => i.Location == to.ToUpper())?.Code; var url = config.ApiUrl.Replace("{from}", fromCode).Replace("{to}", toCode) .Replace("{date}", dateFormatter.BusDate(departureDate)); var headers = new WebHeaderCollection { { "Accept-Language", "ua" } }; var response = await httpService.MakeGetRequestAsync(url, headers); var responseString = await new StreamReader(response.GetResponseStream() ?? throw new InvalidOperationException()).ReadToEndAsync(); var result = Parser.ParseTrips(responseString).ToList(); result.ForEach(t => { t.FromCode = fromCode; t.ToCode = toCode; t.BookingLink = linkBuilder.BuildBusLink(t); }); result.RemoveAll(t => t.DepartureDate < departureDate); return(result); }