public void Budget_Delete(DataModel.eCategory eCat) { List <DataModel.Budget> lBudgets = Budget_RetrieveAll(); List <DataModel.Budget> newBudgets = new List <DataModel.Budget>(); for (int i = 0; i < lBudgets.Count; i++) { if (lBudgets[i].Category != eCat.ToString()) { newBudgets.Add(lBudgets[i]); } } UpdateBudgetsFile(newBudgets); }
private bool ValidateBudget(DataModel.eCategory oCategory) { // Grab all Transactions that have an amount and under the category inputted and they said that they want to include it in the budget. List <DataModel.Transaction> lTransactions = oFactory.oData.RetrieveTransactions().Where(tmpTran => tmpTran.IgnoreBudget == false && tmpTran.Category == oCategory.ToString() && tmpTran.Amount != null && tmpTran.Amount > 0 && DateTime.Parse(tmpTran.TransactionDate).Month == DateTime.Now.Month).ToList(); // Get the budget for the inputted category DataModel.Budget oBudget = oFactory.oData.Budget_RetrieveAll().Where(tmpBudget => tmpBudget.Category == oCategory.ToString()).FirstOrDefault(); if (oBudget != null && !string.IsNullOrEmpty(oBudget.Value) && lTransactions?.Count > 0) { decimal BudgetValue = Convert.ToDecimal(oBudget.Value); decimal TransactionValue = lTransactions.Sum(tmpTran => (decimal)tmpTran.Amount); if (TransactionValue > BudgetValue) { return(false); } } return(true); }