using Microsoft.AspNetCore.Mvc; using ExpenseTracker.Application.Transactions; using ExpenseTracker.Application.Transactions.Commands.Create; using ExpenseTracker.Application.Transactions.Commands.Delete; using ExpenseTracker.Application.Transactions.Commands.Update; using ExpenseTracker.Application.Transactions.Queries.Get; using ExpenseTracker.Application.Common.Models; using ExpenseTracker.Application.Transactions.Queries.GetWithPagination; namespace ExpenseTracker.Api.Controllers; [Route("transactions")] public class TransactionController : BaseController { [HttpPost] public async Task Create([FromBody] CreateTransactionCommand command, CancellationToken cancellationToken) { return await Mediator.Send(command, cancellationToken); } [HttpGet] public async Task> GetPage([FromQuery] GetTransactionsWithPaginationQuery query, CancellationToken cancellationToken) { return await Mediator.Send(query, cancellationToken); } [HttpGet("{id}")] public async Task Get(string id, CancellationToken cancellationToken) { var query = new GetTransactionQuery() { Id = id }; return await Mediator.Send(query, cancellationToken); } [HttpPut] public async Task Update([FromBody] UpdateTransactionCommand command, CancellationToken cancellationToken) { return await Mediator.Send(command, cancellationToken); } [HttpDelete] public async Task Delete([FromBody] DeleteTransactionCommand command, CancellationToken cancellationToken) { await Mediator.Send(command, cancellationToken); } }