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); }
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); }
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); }