Example #1
0
        public JsonResult GetInlineUrlKeys(string botId)
        {
            if (string.IsNullOrEmpty(botId))
            {
                return(Json(false));
            }

            var inlineKeysDto = _inlineUrlKeysRepository.GetUrlInlineUrlKeys(botId);

            return(inlineKeysDto != null
                                ? Json(inlineKeysDto.Select(x => x.Transform()))
                                : Json(false));
        }
        public async Task <IActionResult> Bot(string id)
        {
            var userId = HttpContext.Session.GetString("userId");

            var botsViewModels =
                await BotsService.GetBotsViewModels(_configuration, _systemUserRepository, _botsRepository, userId);

            var botViewModel = await BotsService.GetBotViewModel(id, _configuration, _botsRepository);

            var textMessages     = _textMessageAnswersRepository.GetTextMessageAnswers(id);
            var inlineKeys       = _inlineKeysRepository.GetInlineKeys(id);
            var inlineUrlKeys    = _inlineUrlKeysRepository.GetUrlInlineUrlKeys(id);
            var interviews       = _interviewsRepository.GetInterviews(id);
            var interviewAnswers = _interviewAnswersRepository.GetInterviewAnswers(id).Select(_ =>
                                                                                              new InterviewAnswerViewModel
            {
                Interview       = _interviewsRepository.GetInterview(_.InterviewId),
                InterviewAnswer = _,
                User            = _usersRepository.GetUser(_.UserId, _.BotId)
            });

            var users = _usersRepository.GetUsers(id).Select(_ => new UserViewModel
            {
                Id         = _.Id.ToString(),
                FirstName  = _.FirstName,
                LastName   = _.LastName,
                UserName   = _.UserName,
                TelegramId = _.TelegramId,
                Networking = JsonConvert.DeserializeObject <UserNetworking>(_.Networking)
            });

            return(View(new PageViewModel
            {
                CurrentBot = botViewModel,
                Bots = botsViewModels,
                TextMessages = textMessages,
                InlineKeys = inlineKeys,
                InlineUrlKeys = inlineUrlKeys,
                Interviews = interviews,
                InterviewAnswers = interviewAnswers,
                Users = users
            }));
        }