public async Task <bool> SaveAndProcessCredit(ICreditRepository creditRepositery, int invoiceId, Credit credit) { try { await creditRepositery.StoreNewCreditAsync(invoiceId, credit); credit = await ProcessCreditWithBankAsync(credit); await creditRepositery.UpdateCreditAsync(invoiceId, credit); } catch (Exception e) { _logger.LogError(e, e.Message); return(false); } return(true); }