public void AddIncome() { string incomeDefaultName = CreateUniqueName("Dochody", Incomes.Select(x => x.Name).ToList()); var income = new Income { Name = incomeDefaultName, }; Save(income); CachedService.Clear(CachedServiceKeys.AllIncomes); LoadIncomesData(); }
public void RemoveIncome(Income income, bool omitConfirmation) { if (!omitConfirmation) { var hasIncomeValuesDefined = Database.ExecuteScalar<int>(PetaPoco.Sql.Builder .Select("COUNT(*)") .From("IncomeValue") .Where("IncomeId = @0", income.Id)) > 0; if (hasIncomeValuesDefined) { var message = string.Format("Dochód \"{0}\" jest już używany w budżecie. Usunięcie go spowoduje usunięcie jego wystąpień we wszystkich budżetach.\r\n\r\nCzy chcesz kontynuować?", income.Name); Shell.ShowMessage(message, () => RemoveIncome(income, true), null); return; } } using (var tx = Database.GetTransaction()) { Database.Delete<IncomeValue>("WHERE IncomeId = @0", income.Id); Database.Delete(income); tx.Complete(); } CachedService.Clear(CachedServiceKeys.AllIncomes); LoadIncomesData(); }
public virtual IncomeValue AddIncomeValue(Income income, decimal value, DateTime date, string description) { IncomeValue IncomeValue = income.AddIncomeValue(this, value, date, description); IncomeValues.Add(IncomeValue); return IncomeValue; }
private decimal GetSumOfBudgetIncomes(Income income) { if (income == null) { return Budget.SumOfRevenueIncomes; } return Budget.IncomeValues.Where(x => x.IncomeId == income.Id).Sum(x => x.Value); }
public void RemoveIncome(Income income) { RemoveIncome(income, false); }