internal bool IsRemoteBudgetItemUsedInProfile(BudgetGroup profileGroup, RemoteBudget.RemoteBudgetItem remoteItem) { // Search for matching items in the profile var profileItem = profileGroup.BudgetItems.Where(i => i.Name == remoteItem.Label).FirstOrDefault(); // Only count populated budget items with non-zero values as having been used return(profileItem != null && profileItem.Amount != 0m); }
public async Task RemoveUnusedBudgetItems(string budgetId, RemoteBudget.RemoteBudgetItem remoteItem, BudgetGroup profileGroup) { var profileItem = profileGroup.BudgetItems.Where(i => i.Name == remoteItem.Label).FirstOrDefault(); // Not in the local profile? DELETE! if (!IsRemoteBudgetItemUsedInProfile(profileGroup, remoteItem)) { await remoteBudgetCalls.DeleteBudgetItem(budgetId, remoteItem.Id); } }