コード例 #1
0
        public void StartBot_NormalData_SuccessStart()
        {
            //Arrange
            Account account = new Account
            {
                Bots = new List <BotDB>
                {
                    new BotDB
                    {
                        Markup = "someMarkup",
                        Token  = "someData"
                    }
                },
                Money = 1
            };

            dbContext.Accounts.Add(account);
            dbContext.SaveChanges();

            //Act
            BotStartMessage result = botsAirstripService.StartBot(account.Bots.First().Id, account.Id);

            //Assert
            Assert.IsTrue(result.Success);
            Assert.IsNull(result.FailureReason);
            Assert.IsNull(result.ForestException);
        }
コード例 #2
0
        public IActionResult RunBotForSalesFromDraft(int botId)
        {
            _logger.Log(LogLevel.INFO, Source.WEBSITE, $"Запуск бота. botId={botId}");
            int accountId;

            try
            {
                accountId = HttpClientWrapper.GetAccountIdFromCookies(HttpContext)
                            ?? throw new Exception("Из cookies не удалось извлечь accountId");
            }
            catch
            {
                return(StatusCode(403));
            }
            var answer = _botsAirstripService.StartBot(botId, accountId);

            return(Json(answer));
        }