public AnnualFinancialReport Handle(AnnualFinancialReportQuery request) { var thisMonth = DateTime.Today.AsMonthDate(); var rootTaxon = _dispatcher.Fetch(new TaxonTreeQuery { Deep = 3 }); var builder = new MonthReportBuilder(_dispatcher, rootTaxon); return(new AnnualFinancialReport { Entries = rootTaxon.Elements, Months = Enumerable.Range(-3 + request.ShiftMonth, 12) .Select(thisMonth.AddMonths) .Select(n => GetReportFromCacheOrBuild(n, builder)) .ToList() }); }
private AnnualFinancialReportMonth GetReportFromCacheOrBuild(DateTime thatMonth, MonthReportBuilder builder) { var cacheKey = GetMonthlyReportKey(thatMonth); var report = _cacheStorage.Get <AnnualFinancialReportMonth>(cacheKey); if (report == null) { report = builder.GetReport(thatMonth); _cacheStorage.Set(cacheKey, report); } return(report); }