public void Delete(int id)
        {
            var expense = _repo.GetExpense(id);

            if (expense == null)
            {
                return;
            }
            _repo.Delete(expense);
            _repo.SaveAll();
        }
示例#2
0
        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"));
        }
示例#3
0
        public IActionResult Delete([FromRoute] int id)
        {
            var expense = _expensesRepository.Get(id);

            if (expense == null)
            {
                return(NotFound(NotFoundMessage));
            }
            _expensesRepository.Delete(id);

            return(StatusCode(StatusCodes.Status204NoContent));
        }
示例#4
0
        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();
            });
        }