示例#1
0
        private async Task LoadSuggestions(Chat chat, string name)
        {
            var stops = _stopService.GetStopsByFuzzySearch(name);

            if (!stops.Any())
            {
                await HandleError(chat, new Departure { DepartureResultState = DepartureResultState.StopNotFound });

                return;
            }

            var message       = Strings.ShowDeparturesCommand_DidYouMean;
            var inlineButtons = new List <List <InlineKeyboardButton> >();

            foreach (var stop in stops)
            {
                var button = new InlineKeyboardButton
                {
                    Text         = stop.Name,
                    CallbackData = $"{Commands.QueryLoadCommand}{Commands.QueryDataSeparator}{stop.ShortName}"
                };
                inlineButtons.Add(new List <InlineKeyboardButton> {
                    button
                });
            }

            var markup = new InlineKeyboardMarkup(inlineButtons);
            await _sendMessageService.SendMessage(chat, message, markup);
        }