예제 #1
0
        public void DisplayCurrent()
        {
            RateEntity  rateEntity = new RateEntity();
            List <Rate> rates      = DataFetch.GetRecentRate();
            Rate        minRate    = null;
            Rate        maxRate    = null;
            bool        temp1      = false;
            bool        temp2      = false;

            Console.WriteLine("Enter time in minutes to wat until next reload:");
            int sleepTime = int.Parse(Console.ReadLine()) * 60000;

            if (LastEntity != null)
            {
                Console.WriteLine("Курсы валют на {0}", DateTime.Now.ToString(System.Globalization.CultureInfo.CreateSpecificCulture("fr-FR")));
                showMinMax(LastEntity);
            }
            while (true)
            {
                Thread.Sleep(sleepTime);
                GetMinMax(out minRate, out maxRate, rates);
                AllEntities.ToList();
                if (LastEntity != null)
                {
                    temp1 = LastEntity.MinRate.Equals(minRate);
                    temp2 = LastEntity.MaxRate.Equals(maxRate);
                }

                if (!temp1 || !temp2)
                {
                    Console.Clear();
                    if (RateRegistration(rates, rateEntity))
                    {
                        Console.Clear();
                        Console.WriteLine("Курсы валют на {0}", DateTime.Now.ToString(System.Globalization.CultureInfo.CreateSpecificCulture("fr-FR")));
                        showMinMax(rateEntity);
                        LastEntity = rateEntity;
                    }
                    else
                    {
                        Console.WriteLine("Something went wrong");
                    }
                }
            }
        }