Ejemplo n.º 1
0
        public GameDTO CreateGame(string playerName, int playerCount, bool isPrivate)
        {
            GameDTO returnObj = null;

            GameDTO game = new GameDTO();

            game.CreatedPlayer = playerName;
            game.PlayersCount  = playerCount;
            game.IsPublic      = !isPrivate;

            try
            {
                using (APIService apiClient = new APIService())
                {
                    var         temp   = apiClient.MakePostRequest("api/Game/CreateGame", game);
                    ResultToken result = apiClient.ConvertObjectToToken(temp);
                    if (result.Success && result.Data != null)
                    {
                        returnObj = JsonConvert.DeserializeObject <GameDTO>(result.Data.ToString());
                    }
                }
            }
            catch (Exception ex) {
                Logger logger = LogManager.GetLogger("excpLogger");
                logger.Error(ex);
            }

            return(returnObj);
        }
Ejemplo n.º 2
0
        public ResultToken GenerateJwtToken(string username, string securityKey)
        {
            var claims = new List <Claim>
            {
                new Claim(JwtRegisteredClaimNames.Sub, username),
                new Claim(JwtRegisteredClaimNames.Jti, Guid.NewGuid().ToString()),
            };

            var key     = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(securityKey));
            var creds   = new SigningCredentials(key, SecurityAlgorithms.HmacSha256);
            var expires = DateTime.Now.AddHours(Convert.ToDouble(_configuration["JwtExpireHours"]));

            var token = new JwtSecurityToken(
                _configuration["JwtIssuer"],
                _configuration["JwtIssuer"],
                claims,
                expires: expires,
                signingCredentials: creds
                );

            var userToken = new ResultToken
            {
                AccesToken = new JwtSecurityTokenHandler().WriteToken(token)
            };

            return(userToken);
        }
Ejemplo n.º 3
0
        public ResultToken JoinGame(JoinRequestModel request)
        {
            ResultToken result = new ResultToken();

            result.Success = true;
            try
            {
                if (request.GameId == 0)
                {
                    request.GameId = gameEntities.Games.Where(a => a.GameCode.Equals(request.GameCode)).Select(x => x.GameId).FirstOrDefault();
                }

                Player player = new Player();
                player.GameId       = request.GameId;
                player.PlayerName   = request.PlayerName;
                player.ConnectionId = request.ConnectionId;
                player.IsActive     = true;

                gameEntities.Players.Add(player);
                gameEntities.SaveChanges();
                PlayerDTO playerDTO = Mapping.Mapper.Map <PlayerDTO>(player);
                result.Data = playerDTO;
            }
            catch (Exception ex)
            {
                result.Success = false;
                Logger logger = LogManager.GetLogger("excpLogger");
                logger.Error(ex);
            }

            return(result);
        }
Ejemplo n.º 4
0
        public ResultToken SellStocks(int playerId, StockDetail stock, int quantity, decimal price)
        {
            ResultToken result = null;

            PlayerTransactionsDTO obj = new PlayerTransactionsDTO();

            obj.PlayerId = playerId;
            obj.Stock    = stock;
            obj.Quantity = quantity;
            obj.Price    = price;

            try
            {
                using (APIService apiClient = new APIService())
                {
                    var temp = apiClient.MakePostRequest("api/Broker/SellStocks", obj);
                    result = apiClient.ConvertObjectToToken(temp);
                    if (result != null && result.Success)
                    {
                        result.Data = obj;
                    }
                }
            }
            catch (Exception ex)
            {
                Logger logger = LogManager.GetLogger("excpLogger");
                logger.Error(ex);
            }

            return(result);
        }
Ejemplo n.º 5
0
        public ResultToken RemovePlayer(int playerId)
        {
            ResultToken result = new ResultToken();

            result.Success = true;
            try
            {
                var player = gameEntities.Players.FirstOrDefault(a => a.PlayerId == playerId);
                if (player != null)
                {
                    player.IsActive = false;
                    gameEntities.SaveChanges();
                    //PlayerDTO playerDTO = Mapping.Mapper.Map<PlayerDTO>(player);
                    // result.Data = playerDTO;
                }
            }
            catch (Exception ex)
            {
                result.Success = false;
                Logger logger = LogManager.GetLogger("excpLogger");
                logger.Error(ex);
            }

            return(result);
        }
Ejemplo n.º 6
0
        public ResultToken CreateGame(string playerName, int noOfPlayers, bool isPublic)
        {
            ResultToken result = new ResultToken();

            result.Success = true;
            try
            {
                Game newGame = new Game();
                newGame.StartTime     = DateTime.UtcNow;
                newGame.PlayersCount  = noOfPlayers;
                newGame.CreatedPlayer = playerName;
                newGame.IsPublic      = isPublic;
                newGame.IsActive      = true;
                newGame.GameCode      = GenerateGameCode();
                gameEntities.Games.Add(newGame);
                gameEntities.SaveChanges();
                GameDTO gameDto = Mapping.Mapper.Map <GameDTO>(newGame);
                result.Data = gameDto;
            }
            catch (Exception ex) {
                result.Success = false;
                Logger logger = LogManager.GetLogger("excpLogger");
                logger.Error(ex);
            }
            return(result);
        }
Ejemplo n.º 7
0
        //purchase history
        public ResultToken getPurchasesByPlayer(int playerId)
        {
            ResultToken result = new ResultToken();

            result.Success = true;

            try
            {
                var purchasesByPlayer = viewPortfolio().Where(c => c.PlayerId == playerId && c.Quantity > 0).ToList();

                if (purchasesByPlayer != null)
                {
                    result.Data = purchasesByPlayer;
                    return(result);
                }
                else
                {
                    result.Success = false;
                    result.Message = "No History found.";
                    return(null);
                }
            }
            catch (Exception e)
            {
                result.Success = false;
                result.Message = e.Message;
                return(null);
            }
        }
Ejemplo n.º 8
0
        public ResultToken StartGame(int gameId)
        {
            ResultToken result = new ResultToken();

            result.Success = true;

            var game = gameEntities.Games.FirstOrDefault(a => a.GameId == gameId);

            try {
                if (game != null)
                {
                    game.IsStarted = true;
                    gameEntities.SaveChanges();
                    GameDTO gameDto = Mapping.Mapper.Map <GameDTO>(game);
                    result.Data = gameDto;
                }
            }
            catch (Exception ex)
            {
                result.Success = false;
                Logger logger = LogManager.GetLogger("excpLogger");
                logger.Error(ex);
            }

            return(result);
        }
Ejemplo n.º 9
0
        public async Task <List <ResultToken> > Analyze(string searchPhrase, decimal priceFrom, decimal priceTo)
        {
            List <ResultToken> result = new List <ResultToken>();

            List <Statistic> statistics = await GetStatistics(searchPhrase, priceFrom, priceTo);

            foreach (var statistic in statistics)
            {
                foreach (var token in statistic.Tokens)
                {
                    ResultToken resultToken = result.FirstOrDefault(x => IsEqual(x.Text, token.Text));

                    if (resultToken != null)
                    {
                        resultToken.Views += statistic.Offer.Views;
                        resultToken.Occurences++;
                    }
                    else
                    {
                        result.Add(new ResultToken()
                        {
                            Text       = token.Text,
                            Views      = statistic.Offer.Views,
                            Occurences = 1
                        });
                    }
                }
            }

            result = result.OrderByDescending(x => x.Stat).ToList();

            return(result);
        }
Ejemplo n.º 10
0
        public ResultToken getSalesByPlayer(int playerId)
        {
            ResultToken result = new ResultToken();

            result.Success = true;

            try
            {
                var salesByPlayer = viewPortfolio().Where(c => c.PlayerId == playerId && c.Quantity < 0).ToList();

                if (salesByPlayer != null)
                {
                    foreach (ViewPlayerPortfolio item in salesByPlayer) // set minus quan to positive values
                    {
                        item.Quantity = item.Quantity * -1;
                    }
                    result.Data = salesByPlayer;
                    return(result);
                }
                else
                {
                    result.Success = false;
                    result.Message = "No History found.";
                    return(null);
                }
            }
            catch (Exception e)
            {
                result.Success = false;
                result.Message = e.Message;
                return(null);
            }
        }
Ejemplo n.º 11
0
        public async Task <IActionResult> LoginUser(User user)
        {
            LoginDto loginDto    = ConverteUserToLoginDto(user);
            var      jsonContent = JsonConvert.SerializeObject(loginDto);
            var      content     = new StringContent(jsonContent, Encoding.UTF8, "application/json");

            HttpClient client = new HttpClient();
            var        result = client.PostAsync($"http://{this._host}:{this._port}/auth/api/token/authenticate", content).Result;

            string userToken = null;

            if (result.IsSuccessStatusCode)
            {
                if (result.Content != null)
                {
                    var responseContent = await result.Content.ReadAsStringAsync();

                    ResultToken resultToken = JsonConvert.DeserializeObject <ResultToken>(responseContent);
                    userToken = resultToken.Token;
                }
            }

            if (userToken != null)
            {
                HttpContext.Session.SetString("JWToken", userToken);   //Save token in session object
            }
            return(Redirect("~/Home/Index"));
        }
Ejemplo n.º 12
0
        public ResultToken GetGameTrendList(int gameId)
        {
            ResultToken result = new ResultToken();

            result.Success = true;
            try
            {
                if (!GameDataManager.gameDetails.ContainsKey(gameId))
                {
                    GameDetailDTO gameDetail = new GameDetailDTO();
                    using (TrendService trendService = new TrendService())
                    {
                        gameDetail.RandomTrend = trendService.GenerateRandomTrends();
                        gameDetail.MarketTrend = trendService.GenerateMarketTrends();
                        gameDetail.SectorTrend = trendService.GenerateSectorTrends();
                    }
                    using (EventService eventService = new EventService())
                    {
                        gameDetail.EventDetail = eventService.GenerateEvents();
                    }
                    gameDetail.TurnDetail = calculateTurnScore(gameDetail);

                    GameDataManager.gameDetails.Add(gameId, gameDetail);
                }
                result.Message = "Success! Game Turn Details Generated Successfully.";
                result.Data    = (GameDetailDTO)GameDataManager.gameDetails[gameId];
            }
            catch (Exception ex)
            {
                result.Success = false;
                result.Message = ex.Message;
                Console.WriteLine(ex.ToString());
            }
            return(result);
        }
Ejemplo n.º 13
0
        public ResultToken MakeGetRequest(string transaction)
        {
            ResultToken result = new ResultToken();

            try
            {
                var response = client.GetAsync(transaction).Result;

                if (response.IsSuccessStatusCode)
                {
                    result = response.Content.ReadAsAsync <ResultToken>().Result;
                }
                else
                {
                    Logger logger = LogManager.GetLogger("errorLogger");
                    logger.Error(transaction + " : " + response.StatusCode);
                }
            }
            catch (Exception ex)
            {
                Logger logger = LogManager.GetLogger("excpLogger");
                logger.Error(ex, transaction);
            }

            return(result);
        }
Ejemplo n.º 14
0
 public IHttpActionResult GetSectors()
 {
     using (GameService gameService = new GameService())
     {
         ResultToken token = new ResultToken();
         token.Success = true;
         token.Data    = gameService.GetSectorsList();
         return(Json(token));
     }
 }
Ejemplo n.º 15
0
 public IHttpActionResult GameOver(PlayerDTO winner)
 {
     using (GameService gameService = new GameService())
     {
         ResultToken token = new ResultToken();
         token.Success = true;
         token.Data    = gameService.GameOver(winner);
         return(Json(token));
     }
 }
Ejemplo n.º 16
0
        public ResultToken GetPlayerAIData([FromBody] GameDTO game)
        {
            ResultToken result = new ResultToken();

            result.Success = true;

            PlayerAI player = new PlayerAI(game);

            result.Data = player.returnBuySellList();
            return(result);
        }
Ejemplo n.º 17
0
    protected void btnLogin_Click(object sender, EventArgs e)
    {
        try
        {
            string usuarioText = txtUsuario.Text.ToString();
            string application = txtaplicacion.Text.ToString();

            string formaStringApp = Encoding.ASCII.GetString(Encoding.UTF8.GetBytes(usuarioText + ":" + application));
            var    encrypUserApps = StringCipher.Encrypt(formaStringApp);

            using (WebClient client = new WebClient())
            {
                var jsonData = new { key = encrypUserApps };

                var dataString = JsonConvert.SerializeObject(jsonData);
                client.Headers.Add(HttpRequestHeader.ContentType, "application/json");
                client.UseDefaultCredentials = true;
                string  response   = client.UploadString(urlapi + "Seguridad/UsuarioLogin", "POST", dataString);
                JObject jsonObject = JObject.Parse(response);
                string  jsonToken  = Convert.ToString(jsonObject["data"]);

                ResultToken account = null;
                if (!string.IsNullOrEmpty(jsonToken))
                {
                    account = JsonConvert.DeserializeObject <ResultToken>(jsonToken);
                    if (account != null)
                    {
                        string token     = Base64Encode(JsonConvert.SerializeObject(account.token));
                        string url       = Base64Encode(account.pagina);
                        string usuario   = Base64Encode(account.usuario);
                        string urlFormat = string.Concat(account.url, "?key=", token.ToString(), "&url=", url, "&usr="******"<script>window.open('" + urlFormat + "','_blank');</script>");
                        }
                    }
                    else
                    {
                        Response.Write("<script>alert('Usuario incorrecto')</script>");
                    }
                }
                else
                {
                    Response.Write("<script>alert('Usuario incorrecto')</script>");
                }
            }
        }
        catch (Exception ex)
        {
            throw ex;
        }
    }
Ejemplo n.º 18
0
        List <ResultToken> DFA(string input)
        {
            List <ResultToken> Tokens    = new List <ResultToken>(); //список выходных токенов
            ResultToken        LastToken = null;                     //последний сохранненый токен
            string             Output    = "";                       //выходная строка для токена
            int    CurState    = 0;                                  //текущее состояние
            int    InIndex     = 0;                                  //текщий индекс входной строки
            int    LastInIndex = 0;
            Action Action      = Action.Continue;                    //текущее состояние анализатора

            while (Action != Action.Stop)                            //читаем входную строку пока не получим останов анализатора
            {
                //обнуляем значения при анализе нового токена
                Output    = "";
                CurState  = 0;
                LastToken = null;

                while (CurState != -1) //анализируем входную строку до отсутсвия перехода
                {
                    TokenName temp = FromStateToTokenName(CurState);
                    if (temp != TokenName.Nothing)
                    {
                        LastToken   = new ResultToken(temp.ToString(), Output);
                        LastInIndex = InIndex;
                    }
                    if (InIndex > input.Length - 1)  //проверка на окончания входной строки
                    {
                        Action = Action.Stop;
                        break;
                    }
                    CurState = TransitionTable(CurState, input[InIndex]); //новое состояние из таблицы переходов
                    if (LastToken == null && CurState == -1)              //останавливаем анализатор если попали в неизвестный символ
                    {
                        throw new LexerException(input[InIndex]);
                    }

                    if (CurState > 0) //запись символа в токен (если не пробел)
                    {
                        Output += input[InIndex];
                    }
                    InIndex++;
                }

                InIndex = LastInIndex; //возврат входного символа к последнему успешному токену
                if (LastToken != null)
                {
                    Tokens.Add(LastToken);
                }
            }
            return(Tokens);
        }
Ejemplo n.º 19
0
        //sellStocks()
        public ResultToken sellStocks(int playerID, int quantity, StockDetail stock, decimal price)
        {
            ResultToken result = new ResultToken();

            result.Success = true;
            bool gotSupply    = false;
            bool priceIsRight = false;

            int quantityBalance = checkStockQuantity(playerID, stock.StockId);

            if (quantityBalance >= quantity)
            {
                gotSupply = true;
            }
            else
            {
                result.Success = false;
                result.Message = "Insufficient Stocks";
                return(result);
            }

            priceIsRight = stock.CurrentPrice == price ? true : false;

            int accID = getAccountID(playerID); //acc id for update bank acc details

            if (gotSupply && priceIsRight && accID > 0)
            {
                try
                {
                    playerEntities.SellStocks(playerID, accID, quantity, stock.StockId, price);
                }
                catch (Exception e)
                {
                    result.Success = false;
                    result.Message = e.Message;
                    return(result);
                }
            }
            else
            {
                result.Success = false;
                result.Message = "Transaction incomplete";
                return(result);
            }


            return(result);
        }
Ejemplo n.º 20
0
        //buyStocks()
        public ResultToken buyStocks(int playerID, int quantity, StockDetail stock, decimal price)
        {
            ResultToken result = new ResultToken();

            result.Success = true;
            bool gotMoney     = false;
            bool priceIsRight = false;

            decimal currentAccBalance = checkBankBalance(playerID);

            if (currentAccBalance >= quantity * price)
            {
                gotMoney = true;
            }
            else
            {
                result.Success = false;
                result.Message = "Account balance insufficient";
                return(result);
            }

            priceIsRight = stock.CurrentPrice == price ? true : false;

            int accID = getAccountID(playerID);

            if (gotMoney && priceIsRight && accID > 0)
            {
                try
                {
                    playerEntities.BuyStocks(playerID, accID, quantity, stock.StockId, price);
                }
                catch (Exception e)
                {
                    result.Success = false;
                    result.Message = e.Message;
                    return(result);
                }
            }
            else
            {
                result.Success = false;
                result.Message = "Transaction incomplete";
                return(result);
            }

            return(result);
        }
Ejemplo n.º 21
0
        // GET api/authorization/5
        public ResultToken Get(string key)
        {
            ResultAuthe resultAutho = new ResultAuthe();

            resultAutho.Key = key;
            foreach (string item in arry)
            {
                if (item.Equals(key))
                {
                    resultAutho.Result = true;
                    break;
                }
            }

            ResultToken result = new ResultToken();

            result.Token = DecryptAndEcryptData.Encrypt(JsonConvert.SerializeObject(resultAutho), DecryptAndEcryptData.GetConfigEncrytKey(), DecryptAndEcryptData.IsHashEncryptDecryptEnable());
            return(result);
        }
Ejemplo n.º 22
0
        public async Task <IActionResult> LoginUser(UserEntity user)
        {
            LoginDto loginDto    = ConverteUserToLoginDto(user);
            var      jsonContent = JsonConvert.SerializeObject(loginDto);
            var      content     = new StringContent(jsonContent, Encoding.UTF8, "application/json");


            try
            {
                HttpClient client = new HttpClient();
                var        result = client.PostAsync($"http://{this.host}:{this.port}/auth/Login", content).Result;

                string userToken = null;
                if (result.IsSuccessStatusCode)
                {
                    if (result.Content != null)
                    {
                        var responseContent = await result.Content.ReadAsStringAsync();

                        ResultToken resultToken = JsonConvert.DeserializeObject <ResultToken>(responseContent);
                        userToken = resultToken.accessToken;
                        HttpContext.Session.SetString("Role", resultToken.role.ToString());
                        HttpContext.Session.SetString("IsAuthenticated", true.ToString());
                    }
                }

                if (userToken != null)
                {
                    HttpContext.Session.SetString("JWToken", userToken);  //Save token in session object

                    return(Redirect("~/modulos/Index"));
                }
                else
                {
                    return(Redirect("~/home/Index"));
                }
            }
            catch (Exception e)
            {
                return(RedirectToAction(nameof(Error), new { message = e.Message }));
            }
        }
Ejemplo n.º 23
0
        public async Task <IActionResult> Login([FromBody] AccountModel userData)
        {
            var currentUser = _databaseServices.GetUser(userData.Username);

            if (currentUser == null)
            {
                return(BadRequest("User is not set."));
            }

            if (!_securityServices.ValidatePassword(userData.Password, currentUser.PassHash))
            {
                return(BadRequest("Wrong password"));
            }

            var userToken = new ResultToken
            {
                AccesToken = await _redisRepository.Get(currentUser.TokenKey)
            };

            return(Ok(userToken));
        }
Ejemplo n.º 24
0
        public PlayerDTO CreatePlayer(string playerName, int gameId, string connectionId)
        {
            PlayerDTO returnObj = null;

            JoinRequestModel request = new JoinRequestModel();

            request.PlayerName   = playerName;
            request.GameId       = gameId;
            request.ConnectionId = connectionId;
            try
            {
                using (APIService apiClient = new APIService())
                {
                    var         temp   = apiClient.MakePostRequest("api/Game/JoinGame", request);
                    ResultToken result = apiClient.ConvertObjectToToken(temp);
                    if (result.Success && result.Data != null)
                    {
                        returnObj = JsonConvert.DeserializeObject <PlayerDTO>(result.Data.ToString());
                        if (returnObj != null)
                        {
                            var tempAccount = CreateBankAccount(returnObj);
                            if (tempAccount != null)
                            {
                                returnObj.BankAccount = tempAccount;
                            }
                            else
                            {
                                returnObj = null;
                            }
                        }
                    }
                }
            }
            catch (Exception ex) {
                Logger logger = LogManager.GetLogger("excpLogger");
                logger.Error(ex);
            }

            return(returnObj);
        }
Ejemplo n.º 25
0
        public object GameOver(PlayerDTO winner)
        {
            ResultToken result = new ResultToken();

            result.Success = true;
            try
            {
                var game = gameEntities.Games.FirstOrDefault(a => a.GameId == winner.GameId);
                if (game != null)
                {
                    game.IsStarted  = false;
                    game.IsCanceled = false;
                    game.IsActive   = false;
                    game.Winner     = winner.PlayerName;
                    game.EndTime    = DateTime.Now;
                    gameEntities.SaveChanges();
                    //GameDTO gameDto = Mapping.Mapper.Map<GameDTO>(game);
                    // result.Data = gameDto;
                }
                var details = GameDataManager.gameDetails.FirstOrDefault(a => a.Key == winner.GameId);
                if (details.Value != null)
                {
                    Database.GameDetail temp = new Database.GameDetail();
                    temp.GameId  = winner.GameId;
                    temp.Details = details.Value.ToString();
                    gameEntities.GameDetails.Add(temp);
                    gameEntities.SaveChanges();
                    GameDataManager.gameDetails.Remove(details.Key);
                }
            }
            catch (Exception ex)
            {
                result.Success = false;
                Logger logger = LogManager.GetLogger("excpLogger");
                logger.Error(ex);
            }

            return(result);
        }
Ejemplo n.º 26
0
        public GameDTO StartGame(int gameId)
        {
            GameDTO game = null;

            try
            {
                using (APIService apiClient = new APIService())
                {
                    var         temp   = apiClient.MakePostRequest("api/Game/StartGame", gameId);
                    ResultToken result = apiClient.ConvertObjectToToken(temp);
                    if (result.Success && result.Data != null)
                    {
                        game = JsonConvert.DeserializeObject <GameDTO>(result.Data.ToString());
                    }
                }
            }
            catch (Exception ex)
            {
                Logger logger = LogManager.GetLogger("excpLogger");
                logger.Error(ex);
            }
            return(game);
        }
Ejemplo n.º 27
0
        public ResultToken createBankAccount(int playerId, string playerName)
        {
            ResultToken result = new ResultToken();

            result.Success = true;

            try
            {
                //var accounts = playerEntities.BankAccounts.Where(c => c.AccountName == playerName && c.IsActive == true).FirstOrDefault();

                //if (accounts == null)
                //{
                BankAccount newAccount = new BankAccount();
                newAccount.AccountName = playerName;
                newAccount.PlayerId    = playerId;
                newAccount.Balance     = (decimal)1000;
                newAccount.IsActive    = true;
                playerEntities.BankAccounts.Add(newAccount);
                playerEntities.SaveChanges();

                result.Data = newAccount;
                //}
                //else
                //{
                //    result.Success = false;
                //    result.Message = "Account name already exists";
                //}
            }
            catch (Exception e)
            {
                result.Success = false;
                result.Message = e.Message;
            }

            return(result);
        }
Ejemplo n.º 28
0
        public List <SectorDTO> GetSectors()
        {
            List <SectorDTO> returnObj = new List <SectorDTO>();

            try
            {
                using (APIService apiClient = new APIService())
                {
                    var         temp   = apiClient.MakeGetRequest("api/game/sectors");
                    ResultToken result = apiClient.ConvertObjectToToken(temp);
                    if (result.Success && result.Data != null)
                    {
                        returnObj = JsonConvert.DeserializeObject <List <SectorDTO> >(result.Data.ToString());
                    }
                }
            }
            catch (Exception ex)
            {
                Logger logger = LogManager.GetLogger("excpLogger");
                logger.Error(ex);
            }

            return(returnObj);
        }
Ejemplo n.º 29
0
        public List <AIBuySellDetails> GetPlayerAIData(GameDTO gameobj)
        {
            List <AIBuySellDetails> list = null;

            try
            {
                using (APIService apiClient = new APIService())
                {
                    var         temp   = apiClient.MakePostRequest("api/PlayerAi/GetPlayerAIData", gameobj);
                    ResultToken result = apiClient.ConvertObjectToToken(temp);
                    if (result != null && result.Success)
                    {
                        list = JsonConvert.DeserializeObject <List <AIBuySellDetails> >(result.Data.ToString());
                    }
                }
            }
            catch (Exception ex)
            {
                Logger logger = LogManager.GetLogger("excpLogger");
                logger.Error(ex);
            }

            return(list);
        }
Ejemplo n.º 30
0
        public GameDetailDTO GetGameData(int gameId)
        {
            GameDetailDTO returnObj = new GameDetailDTO();

            try
            {
                using (APIService apiClient = new APIService())
                {
                    var         temp   = apiClient.MakeGetRequest("api/trend?gameId=" + gameId.ToString());
                    ResultToken result = apiClient.ConvertObjectToToken(temp);
                    if (result.Success && result.Data != null)
                    {
                        returnObj = JsonConvert.DeserializeObject <GameDetailDTO>(result.Data.ToString());
                    }
                }
            }
            catch (Exception ex)
            {
                Logger logger = LogManager.GetLogger("excpLogger");
                logger.Error(ex);
            }

            return(returnObj);
        }