示例#1
0
        public static async void ChooseTripIdToEdit(int userId, string message)
        {
            try
            {
                var temp = message;
                if (message == "Назад")
                {
                    StartEditTimetable(userId);
                }
                else if (message == "Отмена")
                {
                    Undo(userId);
                }
                else if (!int.TryParse(temp, out var tempInt))
                {
                    await BotController.Bot.SendTextMessageAsync(userId, "Введите число, которое является ID рейса.");
                }
                else
                {
                    if (!DataBaseContextAdmin.CheckTripId(tempInt))
                    {
                        await BotController.Bot.SendTextMessageAsync(userId, "Введите существующий ID рейса.");
                    }
                    DataBaseContextAdmin.SetTripId(userId, tempInt);
                    await BotController.Bot.SendTextMessageAsync(userId, "Выберите, что будете редактировать.",
                                                                 replyMarkup : KeyboardContainer.CreateTimetableEditTripKeyboard());

                    DataBaseContextAdmin.SetCommandId(userId, (int)AdminCommandStep.ChooseTripColumn);
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
        }
示例#2
0
        public static async void EditTimetable(int userId, string message)
        {
            if (message == "Добавить рейс")
            {
                DataBaseContextAdmin.AddTrip();
                DataBaseContextAdmin.SetTripId(userId, DataBaseContextAdmin.GetLastTripId());
                DataBaseContextAdmin.SetCommandId(userId, (int)AdminCommandStep.DeparturePlace);
                await BotController.Bot.SendTextMessageAsync(userId, "Откуда рейс?",
                                                             replyMarkup : KeyboardContainer.CreateTwoKeyboardAdminButtons());
            }
            if (message == "Редактировать рейс")
            {
                await BotController.Bot.SendTextMessageAsync(userId, "Введите ID рейса для редактирования.",
                                                             replyMarkup : KeyboardContainer.CreateTwoKeyboardAdminButtons());

                DataBaseContextAdmin.SetCommandId(userId, (int)AdminCommandStep.SetTripIdEdit);
            }
            if (message == "Удалить рейс")
            {
                await BotController.Bot.SendTextMessageAsync(userId, "Введите ID рейса для удаления.",
                                                             replyMarkup : KeyboardContainer.CreateTwoKeyboardAdminButtons());

                DataBaseContextAdmin.SetCommandId(userId, (int)AdminCommandStep.SetTripIdDel);
            }
            if (message == "Отмена")
            {
                Undo(userId);
            }
        }