public static Bill GetBill(this LinkToDBDataContext context, int id) { Bill bill = context.Bills.FirstOrDefault(x => x.Id == id).LoadBill(); if (bill.BillHistories.Any()) { List <BillHistoryAverage> avgList = new List <BillHistoryAverage>(); for (int i = 1; i <= 12; i++) { IEnumerable <BillHistory> perMonth = bill.BillHistory.Where(x => x.DatePaid.Month == i); if (perMonth.Any()) { BillHistoryAverage bha = new BillHistoryAverage( new DateTime((i < bill.DueDate.Month) ? bill.DueDate.Year + 1 : bill.DueDate.Year, i, 1), perMonth.Average(x => x.Amount), perMonth.Min(x => x.Amount), perMonth.Max(x => x.Amount), perMonth.Average(x => x.DatePaid.Day) ); avgList.Add(bha); } } bill.BillHistoryAverage = avgList.OrderBy(x => x.Month); } return(bill); }
public DashboardItem(BillHistoryAverage bha) { Date = bha.Month; Amount = bha.Average; IsShared = false; Type = "Bill"; IsPaid = false; }
public DashboardItem(BillHistoryAverage bha) { Date = bha.Month; Amount = bha.Average; IsPastDue = false; IsShared = false; Type = "Bill"; IsPaid = false; }
public static Bill GetBill(this LinkToDBDataContext context, int id) { Bill bill = context.Bills.FirstOrDefault(x => x.Id == id).LoadBill(); if (bill.BillHistories.Any()) { List<BillHistoryAverage> avgList = new List<BillHistoryAverage>(); for (int i = 1; i <= 12; i++) { IEnumerable<BillHistory> perMonth = bill.BillHistory.Where(x => x.DatePaid.Month == i); if (perMonth.Any()) { BillHistoryAverage bha = new BillHistoryAverage( new DateTime((i < bill.DueDate.Month) ? bill.DueDate.Year + 1 : bill.DueDate.Year, i, 1), perMonth.Average(x => x.Amount), perMonth.Min(x => x.Amount), perMonth.Max(x => x.Amount), perMonth.Average(x => x.DatePaid.Day) ); avgList.Add(bha); } } bill.BillHistoryAverage = avgList.OrderBy(x => x.Month); } return bill; }