public Task SendMessage(UserModel userModel, RequestType requestType)
        {
            Responce responce = _requestHandler.Handle(userModel, requestType);

            return(_telegramBotClient.SendTextMessageAsync(
                       userModel.ChatId,
                       responce.TextMessage,
                       ParseMode.Markdown,
                       replyMarkup: responce.Keyboard
                       ));
        }
Beispiel #2
0
        public Responce Handle(UserModel userModel, RequestType request)
        {
            Responce responce;

            switch (request)
            {
            case RequestType.Startup:
            {
                responce = userModel.Student.Group == null
                                                        ? new Responce(_keyboardService.GetKeyboardByRequest(request), "Стартовое меню.")
                                                        : new Responce(_keyboardService.GetKeyboardByRequest(RequestType.GroupMenu), GetGroupInfo(userModel.Student.Group));
                break;
            }

            case RequestType.Backward:
            {
                if (userModel.Requests.Count < 2)
                {
                    return(Handle(userModel, RequestType.Startup));
                }
                return(Handle(userModel, userModel.Requests[userModel.Requests.Count - 2]));
            }

            case RequestType.CreateGroup:
            {
                userModel.Requests.Add(RequestType.CreateGroup);
                responce = new Responce(_keyboardService.GetKeyboardByRequest(request), "Введите название группы: .");
                break;
            }

            case RequestType.JoinGroup:
            {
                userModel.Requests.Add(RequestType.JoinGroup);
                responce = new Responce(_keyboardService.GetKeyboardByRequest(request), "Введите номер группы: .");
                break;
            }

            case RequestType.GroupMenu:
                responce = new Responce(_keyboardService.GetKeyboardByRequest(request), GetGroupInfo(userModel.Student.Group));
                break;

            case RequestType.LeaveGroup:
            {
                _dataProvider.LeaveGroup(userModel);
                responce = new Responce(_keyboardService.GetKeyboardByRequest(RequestType.Startup), "Стартовое меню.");
                break;
            }

            case RequestType.WatchFullSchedule:
            {
                responce = _dataProvider.GetFullShedule(userModel, out string schedule)
                                                        ? new Responce(_keyboardService.GetKeyboardByRequest(RequestType.Backward), schedule)
                                                        : new Responce(_keyboardService.GetKeyboardByRequest(RequestType.Backward), "Расписание не достпуно.");
                break;
            }

            case RequestType.WatchScheduleOnTomorrow:
            {
                responce = _dataProvider.GetSheduleOnTomorrow(userModel, out string schedule)
                                                        ? new Responce(_keyboardService.GetKeyboardByRequest(RequestType.Backward), schedule)
                                                        : new Responce(_keyboardService.GetKeyboardByRequest(RequestType.Backward), "Расписание не достпуно.");
                break;
            }

            case RequestType.WatchScheduleOnToday:
            {
                responce = _dataProvider.GetSheduleOnToday(userModel, out string schedule)
                                                        ? new Responce(_keyboardService.GetKeyboardByRequest(RequestType.Backward), schedule)
                                                        : new Responce(_keyboardService.GetKeyboardByRequest(RequestType.Backward), "Расписание не достпуно.");
                break;
            }

            default:
                responce = new Responce(_keyboardService.GetKeyboardByRequest(RequestType.None), "Введите /start");
                break;
            }
            userModel.Requests.Add(request);
            return(responce);
        }