예제 #1
0
        private List <PhoneMetaInformation> GetPhoneMetaInformation(List <int> ids, List <Transaction> transactions, int months)
        {
            List <PhoneMetaInformation> metas = new List <PhoneMetaInformation>();

            foreach (int id in ids.Distinct())
            {
                if (!m_hardwareContext.HardwareConfigurations.Any(x => x.ConfigId == id))
                {
                    continue;
                }

                Hardware phone = m_hardwareContext.HardwareConfigurations.Where(x => x.ConfigId == id).First();

                if (phone == null)
                {
                    continue;
                }

                TimeSeriesForecast tsf = new TimeSeriesForecast(transactions, phone.PhoneModel);

                if (tsf.IsForecastable())
                {
                    var forecast = tsf.GenerateFutureForecast(months);
                    metas.Add(new PhoneMetaInformation(phone, forecast, months));
                }
            }

            return(metas);
        }
예제 #2
0
        private List <ChartItem> GetCharts(List <int> ids, List <Transaction> transactions, int months)
        {
            List <ChartItem> charts = new List <ChartItem>();

            foreach (int id in ids.Distinct())
            {
                if (!m_hardwareContext.HardwareConfigurations.Any(x => x.ConfigId == id))
                {
                    continue;
                }

                Hardware phone = m_hardwareContext.HardwareConfigurations.Where(x => x.ConfigId == id).First();

                if (phone == null)
                {
                    continue;
                }

                TimeSeriesForecast tsf = new TimeSeriesForecast(transactions, phone.PhoneModel);

                if (tsf.IsForecastable())
                {
                    DateTime today       = DateTime.Today;
                    DateTime twoYearsAgo = new DateTime(today.Year - 2, today.Month, 1);
                    var      forecast    = tsf.GenerateFutureForecast(months);
                    charts.Add(new ChartItem(phone.PhoneModel.GetDisplayName(),
                                             false,
                                             2,
                                             forecast.Where(x => x.Date >= twoYearsAgo).ToList()));
                }
            }
            return(charts);
        }
예제 #3
0
        public void TimeSeriesForecast()
        {
            // Arrange
            var transactions = _tContext.Transactions.ToList();

            // Act
            var tsf = new TimeSeriesForecast(transactions, PhoneModel.iPhone8);

            // Assert
            Microsoft.VisualStudio.TestTools.UnitTesting.Assert.IsTrue(tsf.IsForecastable() == true);
        }