Skip to content

Instantly share code, notes, and snippets.

@marcioduarte89
Created November 12, 2021 17:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save marcioduarte89/761673f8b18eddea04a48aeccd122048 to your computer and use it in GitHub Desktop.
Save marcioduarte89/761673f8b18eddea04a48aeccd122048 to your computer and use it in GitHub Desktop.
Transaction Controller
[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