示例#1
0
        public void Run()
        {
            using PaprikaApiClient client = new PaprikaApiClient();
            using zcryptoContext ctx      = new zcryptoContext();
            List <Buy> activeBuys = DataConsistentController.GetActiveBuys();

            foreach (Buy b in activeBuys)
            {
                API_Market_Price price = client.GetMarketPrice(b.CoinId);
                if (price is not null)
                {
                    if (ctx.ReportedExchangeRates.Where(x => x.BuyId == b.Id).Count() > 1000)
                    {
                        ctx.ReportedExchangeRates.RemoveRange(ctx.ReportedExchangeRates.Where(x => x.BuyId == b.Id));
                        ctx.SaveChanges();
                    }
                    ctx.ReportedExchangeRates.Add(new ReportedExchangeRate()
                    {
                        BuyId         = b.Id,
                        PlnExchange   = price.quotes.PLN.price,
                        ApiUpdateTime = price.last_updated,
                        ExchangeDiff  = (price.quotes.PLN.price * (double)b.Count) - (double)(b.ExchangeRatePln * b.Count)
                    });
                    ctx.SaveChanges();
                }
            }
        }
示例#2
0
 public void GetActiveBuysJustActive()
 {
     foreach (Buy b in DataConsistentController.GetActiveBuys())
     {
         Assert.IsTrue(b.Active);
     }
 }
示例#3
0
        public void IsCointBlacklisted()
        {
            zcryptoContext ctx = new zcryptoContext();

            foreach (Coin c in ctx.Coins)
            {
                Assert.DoesNotThrow(() => { DataConsistentController.IsCoinBlacklisted(c.Id); });
            }
        }
 public IActionResult GetActiveCoinIds()
 {
     try
     {
         return(Ok(DataConsistentController.GetActiveCoinsIds()));
     }
     catch (Exception e)
     {
         return(BadRequest(e.Message));
     }
 }
 public IActionResult GetBuy()
 {
     try
     {
         return(Ok(DataConsistentController.GetActiveBuysWithReportedExchangeRates().Take(20)));
     }
     catch (Exception e)
     {
         return(BadRequest(e.Message));
     }
 }
示例#6
0
        public void GetAllCoins()
        {
            DataConsistentController.SynchronizeCoins();

            using (PaprikaApiClient client = new PaprikaApiClient())
            {
                Assert.DoesNotThrow(() =>
                {
                    List <API_Coin> coins = client.GetAllCoins();
                    Assert.IsTrue(coins.Count > 0);
                });
            }
        }