public IEnumerable <TEntity> GetAllEntities() { foreach (var snapshot in _snapshotStore.GetAllSnapshots <TSnapshot>()) { yield return(LoadEntityFromSnapshot(snapshot)); } }
private void PopulateCategoryMonthData(CategoryResultsDictionary results) { var categoryMonths = _snapshotStore.GetAllSnapshots <CategoryMonthSnapshot>(); foreach (var categoryMonth in categoryMonths) { if (categoryMonth.AmountBudgeted == 0M && categoryMonth.NegativeBalanceHandling == null) { continue; } CategoryMonthKey monthKey = new CategoryMonthKey(categoryMonth.Parent, categoryMonth.Month); BudgetViewCategoryMonth monthResult = null; BudgetViewCategoryMonth monthValues = null; if (results.TryGetValue(monthKey, out monthValues)) { if (categoryMonth.AmountBudgeted != 0M) { monthValues.AmountBudgeted = GetCategoryMonthAmount(categoryMonth); } if (categoryMonth.NegativeBalanceHandling != null) { monthValues.NegativeBalanceHandlingIsExplicit = true; monthValues.NegativeBalanceHandling = categoryMonth.NegativeBalanceHandling.Value; } } else { monthResult = new BudgetViewCategoryMonth(monthKey.EntityID, monthKey.FirstDayOfMonth); if (categoryMonth.AmountBudgeted != 0M) { monthResult.AmountBudgeted = GetCategoryMonthAmount(categoryMonth); } if (categoryMonth.NegativeBalanceHandling != null) { monthResult.NegativeBalanceHandlingIsExplicit = true; monthResult.NegativeBalanceHandling = categoryMonth.NegativeBalanceHandling.Value; } results[monthKey] = monthResult; } } }
public IEnumerable <TEntity> GetAllEntities() { var snapshots = _snapshotStore.GetAllSnapshots <TSnapshot>().ToList(); var subEntitySnapshots = GetSubEntitySnapshotLookup(snapshots); foreach (var snapshot in snapshots) { if (subEntitySnapshots == null) { yield return(LoadEntityFromSnapshot(snapshot, null)); } else { EntityReference snapshotReference = new EntityReference(typeof(TEntity).Name, snapshot.EntityID); List <EntitySnapshot> subEntities = null; if (!subEntitySnapshots.TryGetValue(snapshotReference, out subEntities)) { subEntities = new List <EntitySnapshot>(); } yield return(LoadEntityFromSnapshot(snapshot, subEntities)); } } }