private void Credit(Account account, Account internalAccount, Movement movement) { MovementHelpers.Credit(HistoricMovementRepository, movement.Amount, account.Id, ObjectType.Account, account.CurrentBalance, internalAccount.Id, ObjectType.Account, internalAccount.CurrentBalance); account.CurrentBalance += movement.Amount; BankAccountRepository.Update(account); internalAccount.CurrentBalance -= movement.Amount; BankAccountRepository.Update(internalAccount); if (!movement.TargetIncomeId.HasValue) { throw new ArgumentException("Target Income ID should not be null."); } var income = IncomeRepository.GetById(movement.TargetIncomeId.Value); IncomeRepository.Delete(income); }
public async Task <ActionResult> DeleteIncomeAsync(int id) { var income = await incomeRepository.GetByIdAsync(id, exp => exp.Budget); if (income == null) { return(NotFound($"No Expense with Id {id} found.")); } if (!IsUserAuthorizedForResource(income.Budget)) { return(Unauthorized("You can only access your own expenses.")); } incomeRepository.Delete(income); var saveResults = await incomeRepository.SaveAllAsync(); if (!saveResults) { return(BadRequest("Failed to delete the income.")); } return(NoContent()); }
public ActionResult DeleteConfirmed(int id) { incomeRepository.Delete(id); incomeRepository.SaveChanges(); return(RedirectToAction("Index")); }
public void DeleteIncome(int IncomeId) { var Income = IncomeRepository.GetById(IncomeId); IncomeRepository.Delete(Income); }