Пример #1
0
        public async Task <SearchResultModel> checkTickets(Station stationFrom, Station stationTill, DateTime?depDateNullable = null)
        {
            DateTime depDate      = depDateNullable ?? DateTime.Now;
            var      searchParams = new TicketSearchParameter(stationFrom, stationTill, depDate.ToString("dd.MM.yyyy"));

            String stringResult = await checkBookings(searchParams);

            var result = JsonConvert.DeserializeObject <SearchResultModel>(stringResult, new SearchResultModelConvertor());

            return(result);
        }
Пример #2
0
        private async Task <String> checkBookings(TicketSearchParameter parameters)
        {
            var content = new FormUrlEncodedContent(new[]
            {
                new KeyValuePair <string, string>("station_id_from", parameters.StationFrom.StationId),
                new KeyValuePair <string, string>("station_id_till", parameters.StationTill.StationId),
                new KeyValuePair <string, string>("station_from", parameters.StationFrom.StationName),
                new KeyValuePair <string, string>("station_till", parameters.StationTill.StationName),
                new KeyValuePair <string, string>("date_dep", parameters.DepartureDate.ToString(new CultureInfo("de-DE"))),
                new KeyValuePair <string, string>("time_dep", "00:00"),
                new KeyValuePair <string, string>("time_dep_till", ""),
                new KeyValuePair <string, string>("another_ec", "0"),
                new KeyValuePair <string, string>("search", "")
            });
            HttpResponseMessage response = await _client.PostAsync("/purchase/search/", content);

            String result = await response.Content.ReadAsStringAsync();

            //if (response.IsSuccessStatusCode)
            //{
            //    return result;
            //}
            return(result);
        }