using AutobusApi.Application.Common.Models; using AutobusApi.Application.Buses.Commands.CreateBus; using AutobusApi.Application.Buses.Commands.DeleteBus; using AutobusApi.Application.Buses.Commands.UpdateBus; using AutobusApi.Application.Buses.Queries; using AutobusApi.Application.Buses.Queries.GetBusesWithPagination; using AutobusApi.Application.Buses.Queries.GetBus; using Microsoft.AspNetCore.Mvc; namespace AutobusApi.Api.Controllers; [Route("vehicle/buses")] public class BusController : BaseController { [HttpPost] public async Task Create([FromBody] CreateBusCommand command, CancellationToken cancellationToken) { return await Mediator.Send(command, cancellationToken); } [HttpGet] public async Task> GetPage([FromQuery] GetBusesWithPaginationQuery query, CancellationToken cancellationToken) { return await Mediator.Send(query, cancellationToken); } [HttpGet("{id}")] public async Task Get(int id, /* [FromQuery] GetBusQuery query, */ CancellationToken cancellationToken) { var query = new GetBusQuery() { Id = id }; return await Mediator.Send(query, cancellationToken); } [HttpPut] public async Task Update([FromBody] UpdateBusCommand command, CancellationToken cancellationToken) { await Mediator.Send(command, cancellationToken); } [HttpDelete("{id}")] public async Task Delete(int id, /* [FromBody] DeleteBusCommand command, */ CancellationToken cancellationToken) { var command = new DeleteBusCommand() { Id = id }; await Mediator.Send(command, cancellationToken); } }