コード例 #1
0
        public async Task <IActionResult> Bet([FromBody] BetModel betModel)
        {
            var steamId = User.GetSteamId();

            var itemsToBet = betModel.Items.Select(item => new AssetAndDescriptionId
            {
                AssetId       = item.AssetId,
                DescriptionId = item.DescriptionId,
            }).ToList();

            await _coinFlipManager.PlaceBet(itemsToBet, betModel.RoundId, steamId);

            return(new OkResult());
        }
コード例 #2
0
        public async Task <IActionResult> RandomUserBetsOnCoinFlip(int lookUpId, int nrOfSkins = 5)
        {
            if (nrOfSkins <= 0)
            {
                return(BadRequest("NrOfSkins needs to be grater than 0"));
            }

            if (nrOfSkins > 10)
            {
                return(BadRequest("NrOfSkins needs to be CAN'T be grater than 10"));
            }

            var user = await _repoServiceFactory.UserRepoService.FindAsync("randomSteamId");

            var itemDesc = await _repoServiceFactory.ItemDescriptionRepoService.FindAsync("Chroma 2 case");

            if (user == null)
            {
                var insertUser = new DatabaseModel.User("randomSteamId", "Rip skins", "b2/b2f83f910fe134cd063357c0a90517ce224a4c04", "Tradelnik",
                                                        DateTime.Now,
                                                        DateTime.Now,
                                                        false);
                user = await _repoServiceFactory.UserRepoService.InsertAsync(insertUser);
            }

            var bots = await _repoServiceFactory.BotRepoService.GetAll();

            var botId = bots.First().Id;

            for (int i = 0; i < nrOfSkins; i++)
            {
            }
            var random1 = RandomString(10);
            var random2 = RandomString(10);
            var random3 = RandomString(10);
            var random4 = RandomString(10);

            try
            {
                await _repoServiceFactory.ItemRepoService.InsertAsync(new DatabaseModel.Item(random1, itemDesc.Id, botId, user.Id, DateTimeOffset.Now));

                await _repoServiceFactory.ItemRepoService.InsertAsync(new DatabaseModel.Item(random2, itemDesc.Id, botId, user.Id, DateTimeOffset.Now));

                await _repoServiceFactory.ItemRepoService.InsertAsync(new DatabaseModel.Item(random3, itemDesc.Id, botId, user.Id, DateTimeOffset.Now));

                await _repoServiceFactory.ItemRepoService.InsertAsync(new DatabaseModel.Item(random4, itemDesc.Id, botId, user.Id, DateTimeOffset.Now));
            }
            catch (System.Exception e)
            {
                // ignored
            }

            _coinFlipManager.PlaceBet(new List <AssetAndDescriptionId>
            {
                new AssetAndDescriptionId {
                    AssetId = random1, DescriptionId = itemDesc.Id
                },
                new AssetAndDescriptionId {
                    AssetId = random2, DescriptionId = itemDesc.Id
                },
                new AssetAndDescriptionId {
                    AssetId = random3, DescriptionId = itemDesc.Id
                },
                new AssetAndDescriptionId {
                    AssetId = random4, DescriptionId = itemDesc.Id
                },
            }, lookUpId, user.SteamId);

            return(Ok());
        }