public async Task <IEnumerable <ITrip> > FindTripsAsync(string from, string to, DateTime departureDate) { var fromStation = await GetStationsInfo(from); var toStation = await GetStationsInfo(to); if (!fromStation.Any() || !toStation.Any()) { return(new List <ITrip>()); } var data = $"from={fromStation.First().Value}"; data += $"&to={toStation.First().Value}"; data += $"&date={dateFormatter.RailwayDate(departureDate)}"; data += $"&time={dateFormatter.RailwayTime(departureDate)}"; var response = await httpService.MakePostRequestAsync(config.ApiUrl, data); var responseString = await new StreamReader(response.GetResponseStream() ?? throw new InvalidOperationException()).ReadToEndAsync(); var result = JsonConvert.DeserializeObject <TrainsInfo>(responseString); result.Data.List.RemoveAll(i => !i.Types.Any()); foreach (var train in result.Data.List) { train.DepartureDate = DateTime.ParseExact(train.From.Date.Split(',')[1].Replace(".", "/").Trim(), "dd/MM/yyyy", CultureInfo.InvariantCulture); train.DepartureDate += train.From.Time; train.ArrivalDate = DateTime.ParseExact(train.To.Date.Split(',')[1].Replace(".", "/").Trim(), "dd/MM/yyyy", CultureInfo.InvariantCulture); train.ArrivalDate += train.To.Time; train.BookingLink = linkBuilder.BuildRailwayLink(train); } return(result.Data.List); }