public async Task <ForecastReportViewModel> GetForecastReportByCompany(string companyCode) { var businessResults = await _businessResultRepository.Query(t => t.Company.Code == companyCode && (t.EndDate.Month - t.StartDate.Month == 11) && !t.IsDeleted) .OrderByDescending(t => t.StartDate) .Take(4) .ToListAsync(); var balanceSheets = await _balanceSheetRepository.Query(t => t.Company.Code == companyCode && (t.EndDate.Month - t.StartDate.Month == 11) && !t.IsDeleted) .OrderByDescending(t => t.StartDate) .Take(4) .ToListAsync(); var forecastBusinessResults = CalculateAverageIndicatorsBusinessResult(businessResults); var forecastBalanceSheets = CalculateAverageIndicatorsBalanceSheet(balanceSheets); var vm = new ForecastReportViewModel() { IndicatorsBalanceSheet = forecastBalanceSheets, IndicatorsBusinessResult = forecastBusinessResults, LatestBalanceSheetByAnnual = _mapper.Map <BalanceSheetViewModel>(balanceSheets.FirstOrDefault()), LatestBusinessResultByAnnual = _mapper.Map <BusinessResultViewModel>(businessResults.FirstOrDefault()) }; return(vm); }
public void CreatesWithForecast() { var location = new Location { Id = 100, Name = "Area 1" }; var service = new MockMountainWeatherService(); var dialogProvder = new Mock <IDialogProvider>(); var viewModel = new ForecastReportViewModel(location, dialogProvder.Object, service); viewModel.LoadForecast(); Assert.That(viewModel.Items, Is.Not.Null); Assert.That(viewModel.Items.Count(), Is.EqualTo(5)); }