public async Task Delete(int id, bool onlyMark = true) { if (onlyMark) { throw new NotSupportedException("Операция не поддерживается"); } var bill = await _repository.LoadAsync <ExpenseBill>(id); if (bill == null) { throw new ArgumentException($"Нет чека с Id = {id}"); } var account = bill.AccountId != null ? await _repository.LoadAsync <Account>(bill.AccountId.Value) : null; if (account != null) { var balanceUpdater = _balancesUpdaterFactory.Create(account.AccountType); await balanceUpdater.Delete(bill); } await _transactionBuilder.DeleteExpense(bill).ConfigureAwait(false); _repository.Delete(bill); await _repository.SaveChangesAsync().ConfigureAwait(false); }