Skip to content

Commit

Permalink
Implement remaining GraphQL operations for transactions. Resolves #68
Browse files Browse the repository at this point in the history
  • Loading branch information
RobinTTY committed Oct 18, 2024
1 parent 7606718 commit 9cfa526
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,17 @@ public async Task<Transaction> CreateTransaction(TransactionRepository repositor
return transaction;
}

/// <summary>
/// Update an existing transaction.
/// </summary>
/// <param name="repository">The injected repository to use for data retrieval.</param>
/// <param name="transaction">The transaction to update.</param>
public async Task<Transaction> UpdateTransaction(TransactionRepository repository,
Transaction transaction)
{
return await repository.UpdateTransaction(transaction);
}

/// <summary>
/// Delete an existing transaction.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,14 +77,15 @@ public async Task<Transaction> AddTransaction(Transaction transaction)
/// <summary>
/// Updates an existing <see cref="Transaction"/>.
/// </summary>
/// <param name="transactionDto">The <see cref="Transaction"/> to update.</param>
/// <param name="transaction">The <see cref="Transaction"/> to update.</param>
/// <returns>The updated <see cref="Transaction"/>.</returns>
/// TODO: return Transaction not TransactionEntity
public async Task<TransactionEntity> UpdateTransaction(TransactionEntity transactionDto)
public async Task<Transaction> UpdateTransaction(Transaction transaction)
{
var updateEntry = _dbContext.Transactions.Update(transactionDto);
var transactionEntity = _transactionMapper.ModelToEntity(transaction);
var updateEntry = _dbContext.Transactions.Update(transactionEntity);
await _dbContext.SaveChangesAsync();
return updateEntry.Entity;

return _transactionMapper.EntityToModel(updateEntry.Entity);
}

/// <summary>
Expand Down

0 comments on commit 9cfa526

Please sign in to comment.