public void Delete(int id) { var expense = _repo.GetExpense(id); if (expense == null) { return; } _repo.Delete(expense); _repo.SaveAll(); }
public ActionResult DeleteConfirmed(int id) { var expenseVm = new ExpenseViewModel(); expenseVm.Expense = _expenseRepository.GetWhereWithIncludes(e => e.Id == id, x => x.BankAccount, x => x.SubCategory, x => x.Category).FirstOrDefault(); _expenseRepository.Delete(expenseVm.Expense); _bankAccountLogic.CalculateBalanceOfAllAccounts(); return(RedirectToAction("Index")); }
public IActionResult Delete([FromRoute] int id) { var expense = _expensesRepository.Get(id); if (expense == null) { return(NotFound(NotFoundMessage)); } _expensesRepository.Delete(id); return(StatusCode(StatusCodes.Status204NoContent)); }
public MainViewModel() : this(new ExpensesRepository()) { DeleteExpenseCommand = new Command <Expense>(async(exp) => { var accepte = await Application.Current.MainPage.DisplayAlert($"Delete Expense:{exp.Title}", "Are you sure?", "Yes,delete it", "Cancel"); if (!accepte) { return; } _expensesRepository.Delete(exp); OnPushed(); }); }