Пример #1
0
        private async Task <DialogTurnResult> DestinationConfirmStepAsync(WaterfallStepContext stepContext, CancellationToken cancellationToken)
        {
            var bookingDetails = (BookingDetails)stepContext.Options;

            bookingDetails.Destination = (string)stepContext.Result;

            var cityApiManager = new CityApiManager(Configuration, httpClient);

            var countryResponse = await cityApiManager.ExecuteGetRequest(bookingDetails.Destination);

            var country = await countryResponse.Content.ReadAsAsync <CityModel>();

            var countryList = country.Data;

            if (countryList.Count > 1)
            {
                return(await stepContext.PromptAsync(nameof(TextPrompt), new PromptOptions
                                                     { Prompt = MessageFactory.Text("There are some variants, choose one :\n" +
                                                                                    this.CreateList(countryList)) }, cancellationToken));
            }
            else
            {
                return(await stepContext.NextAsync(bookingDetails.Destination, cancellationToken));
            }
        }
Пример #2
0
        private async Task <string> ReturnCity()
        {
            var result = await CityApiManager.ReturnCity(bookingDetails.Destination);

            var resultString = bookingDetails.PossibleVariants.Count <= 1 ?
                               result.Data[0].Country : result.Data[int.Parse(bookingDetails.PossibleVariants[0]) - 1].Country;

            return(resultString);
        }
Пример #3
0
        public CommonApiManager(IConfiguration configuration, HttpClient httpClient, BookingDetails bookingDetails)
        {
            this.bookingDetails = bookingDetails;
            this.configuration  = configuration;
            this.httpClient     = httpClient;

            CityApiManager     = new CityApiManager(configuration, httpClient);
            CountryApiManager  = new CountryApiManager(configuration, httpClient);
            CurrencyApiManager = new CurrencyApiManager(configuration, httpClient);
            WeatherApiManager  = new WeatherApiManager(configuration, httpClient);
        }