Ejemplo n.º 1
0
        public void GetDollaresAPI()
        {
            DateTime StartDate = DateTime.Now.AddDays(-10);
            DateTime EndDate   = DateTime.Now;

            var dollares = database.GetDollares();

            if (dollares.Count > 0)
            {
                StartDate = dollares.OrderByDescending(d => d.DataHoraCotacao).FirstOrDefault().DataHoraCotacao.AddDays(1);
                EndDate   = DateTime.Today;
            }

            var result = endpoints.GetDollars(StartDate, EndDate);

            foreach (var item in result)
            {
                if (dollares
                    .Where(d =>
                           d.DataHoraCotacao.ToShortDateString()
                           .Equals(item.DataHoraCotacao.ToShortDateString()))
                    .Count()
                    .Equals(0))
                {
                    database.AddDollar(item.CotacaoCompra, item.CotacaoVenda, item.DataHoraCotacao);
                }
            }
        }
Ejemplo n.º 2
0
        public void GetAriaryAPI()
        {
            DateTime StartDate = DateTime.Now.AddDays(-10);
            DateTime EndDate   = DateTime.Now;

            var dollares = database.GetAriary();

            if (dollares.Count > 0)
            {
                StartDate = dollares.OrderByDescending(d => d.DateTimeQuota).FirstOrDefault().DateTimeQuota.AddDays(1);
                EndDate   = DateTime.Today;
            }

            var result = endpoints.GetDollars(StartDate, EndDate);

            foreach (var item in result)
            {
                if (dollares
                    .Where(d =>
                           d.DateTimeQuota.ToShortDateString()
                           .Equals(item.DateTimeQuota.ToShortDateString()))
                    .Count()
                    .Equals(0))
                {
                    database.AddDollar(item.PurchaseQuota, item.QuotationSale, item.DateTimeQuota);
                }
            }
        }