コード例 #1
0
        public async Task <dynamic> MakeWithdrawOffer([FromBody] WithdrawOfferModel withdrawModel)
        {
            if (!TryValidateModel(withdrawModel))
            {
                return(BadRequest(withdrawModel));
            }

            var steamId = User.GetSteamId();
            var items   = withdrawModel.Items.Select(item => new AssetAndDescriptionId
            {
                AssetId       = item.AssetId,
                DescriptionId = item.DescriptionId
            }).ToList();

            if (_betOrWithdrawQueueManager.DoesExist(steamId))
            {
                return(new StatusCodeResult(503));
            }
            _betOrWithdrawQueueManager.Add(steamId, QueueAction.Withdraw);
            try
            {
                var res = await _steamService.MakeWithdrawOfferAsync(steamId, items);

                return(res);
            }
            catch (TradeLinkNotSetExeption)
            {
                return(BadRequest("User does not have a valid tradelink"));
            }
            finally
            {
                _betOrWithdrawQueueManager.Remover(steamId);
            }
        }