-
-
Save marcioduarte89/761673f8b18eddea04a48aeccd122048 to your computer and use it in GitHub Desktop.
Transaction Controller
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[Route("api/[controller]")] | |
[ApiController] | |
public class TransactionController : ControllerBase | |
{ | |
private readonly ITransactionService _transactionService; | |
public TransactionController(ITransactionService transactionService) | |
{ | |
_transactionService = transactionService; | |
} | |
[HttpPost] | |
public async Task<IActionResult> Create([FromBody] DTOs.Transaction transaction, CancellationToken cancellationToken) | |
{ | |
var transactionId = Guid.NewGuid(); | |
await _transactionService.CreateTransaction(new Transaction() | |
{ | |
Id = transactionId, | |
UserId = transaction.UserId, | |
Value = transaction.Value | |
}, cancellationToken); | |
return Created($"/transaction/{transactionId}", transactionId); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment