public IEnumerable <SheetListing> GetAll(int ownerId) { IEnumerable <SheetListing> sheets = this.GetAllCore(ownerId); // generate a fake sheet entry if none are available // when the sheet will be requested initially, the 'real' // sheet entry will be created var all = sheets.DefaultIfEmpty( AutoMapper.Mapper.Map <Sheet, SheetListing>(this.CreateCurrentMonthSheet(ownerId))); SheetTotals totals = new SheetTotals { BankAccount = 0, SavingsAccount = 0 }; foreach (SheetListing listing in all) { totals.BankAccount += listing.Totals.BankAccount ?? 0; totals.SavingsAccount += listing.Totals.SavingsAccount ?? 0; listing.Totals.BankAccount = totals.BankAccount; listing.Totals.SavingsAccount = totals.SavingsAccount; yield return(listing); } }
public IEnumerable<SheetListing> GetAll(int ownerId) { IEnumerable<SheetListing> sheets = this.GetAllCore(ownerId); // generate a fake sheet entry if none are available // when the sheet will be requested initially, the 'real' // sheet entry will be created var all = sheets.DefaultIfEmpty( AutoMapper.Mapper.Map<Sheet, SheetListing>(this.CreateCurrentMonthSheet(ownerId))); SheetTotals totals = new SheetTotals{BankAccount = 0, SavingsAccount = 0}; foreach (SheetListing listing in all) { totals.BankAccount += listing.Totals.BankAccount ?? 0; totals.SavingsAccount += listing.Totals.SavingsAccount ?? 0; listing.Totals.BankAccount = totals.BankAccount; listing.Totals.SavingsAccount = totals.SavingsAccount; yield return listing; } }