예제 #1
0
        private async Task UpdatePriceing(string url, int appId)
        {
            _logger.Info($"Starting price update for {SteamPaymentMethodToAppId.ToEnum(appId).ToString()}");
            var jObject = await _httpRequestParser.ExecuteAsJObject(new RequestMessage(HttpMethod.Get, url));

            var steamPrices = new SteamPricing
            {
                Id          = SteamPaymentMethodToAppId.ToEnum(appId),
                Items       = new List <SteamItemPrice>(),
                LastUpdated = DateTimeOffset.Now
            };

            using (var cureser = jObject.GetEnumerator())
            {
                while (cureser.MoveNext())
                {
                    var name  = cureser.Current.Key.ToString();
                    var price = decimal.Parse(cureser.Current.Value.ToString());

                    steamPrices.Items.Add(new SteamItemPrice
                    {
                        Value           = Math.Round(price, 2),
                        MarketHashName  = name,
                        ContextId       = 2,
                        LastUpdated     = DateTimeOffset.Now,
                        BackgroundColor = null,
                        IconUrl         = null,
                        NameColor       = null,
                    });
                }

                await _pricingRepository.InsertOrUpdateAsync(steamPrices);

                _logger.Info($"Pricing for {SteamPaymentMethodToAppId.ToEnum(appId).ToString()} done");
            }
        }
예제 #2
0
 public async Task InsertOrUpdateAsync(SteamPricing steamPricing)
 {
     await _repository.SaveAsync(steamPricing);
 }