private void AttachTotal(WeekReportModel report) { DailyReportModel day = report.DailyReports.FirstOrDefault(); DailyReportModel totalForDay = new DailyReportModel(report); foreach (var dept in day.SectionsPerDepartment) { var totalForDepartment = new DepartmentSection(totalForDay); totalForDepartment.Department = dept.Department; totalForDay.SectionsPerDepartment.Add(totalForDepartment); foreach (var bank in dept.BankSections) { if (bank.IsTotalPerDay) { var totalForBank = new DayTotal(totalForDepartment); totalForBank.Bank = new Bank() { Id = 0, BankName = "Sub Total" }; totalForDepartment.BankSections.Add(totalForBank); } else { var totalForBank = new WeekTotalForBank(totalForDepartment); totalForBank.Bank = bank.Bank; totalForDepartment.BankSections.Add(totalForBank); } } } report.DailyReports.Add(totalForDay); }
private void CreateSectionsPerBank(List <Bank> banksInDepartment, DepartmentSection deptSection) { foreach (var b in banksInDepartment) { var bankSection = new BankSection(deptSection); bankSection.Bank = b; bankSection.Checks = _checks.Where(c => c.Bank.Id == b.Id).ToList(); deptSection.BankSections.Add(bankSection); } //This will add total at the bottom. DayTotal total = new DayTotal(deptSection); total.Bank = new Bank() { Id = 0, BankName = "Total" }; deptSection.BankSections.Add(total); }