public Payee(Data.Models.Payee data) { this.ID = data.ID; this.Name = data.Name; this.Active = data.Active; this.CategoryID = data.CategoryID; this.Category = new SqlDataServices <Data.Models.Category>().Get(CategoryID)?.Name; }
public IncomeExpensePayee(Data.Models.Payee data, DateTime startDate, DateTime endDate, int averageDividend, bool positive = true) { IEnumerable <Data.Models.Transactions> transactions; if (positive) { transactions = new SqlDataServices <Data.Models.Transactions>().GetAll(data.ID, typeof(Data.Models.Category)).Where(e => e.Date >= startDate && e.Date <= endDate && e.Amount > 0); this.IncomeOrExpense = CategoryType.Income; } else { transactions = new SqlDataServices <Data.Models.Transactions>().GetAll(data.ID, typeof(Data.Models.Category)).Where(e => e.Date >= startDate && e.Date <= endDate && e.Amount < 0); this.IncomeOrExpense = CategoryType.Expense; } this.Name = data.Name; this.Total = transactions.Select(e => e.Amount).Sum(); this.Average = this.Total / averageDividend; }