private static decimal CalculatePredictExchange(string fromCurrency, string toCurrency, DateTime date)
        {
            var begindate = new DateTime(date.AddMonths(-11).Year, date.AddMonths(-11).Month, 15);

            if (date.Day < 15)
            {
                begindate = new DateTime(date.AddMonths(-12).Year, date.AddMonths(-12).Month, 15);
            }

            var datas = ExchangeRateService.GetPreviousExchangeData(begindate, fromCurrency, toCurrency);

            var     calc = Calculator.LinearRegression(datas);
            decimal a    = calc.X; //  intercept
            decimal b    = calc.Y; //  slope

            return(a + b * 13);
        }
        public static bool IsValid(string fromCurrency, string toCurrency)
        {
            // currency must have three character
            var result = true;

            if (fromCurrency.Length != 3 || toCurrency.Length != 3)
            {
                return(result = false);
            }
            // currency must be in the list currency which take from website
            Dictionary <string, string> currencylist = ExchangeRateService.FetchCurrency();

            if (!currencylist.Keys.Contains(fromCurrency.ToUpper()) || !currencylist.Keys.Contains(toCurrency.ToUpper()))
            {
                return(result = false);
            }


            return(result);
        }