using AutobusApi.Application.Common.Models; using AutobusApi.Application.Countries.Commands.CreateCountry; using AutobusApi.Application.Countries.Commands.DeleteCountry; using AutobusApi.Application.Countries.Commands.UpdateCountry; using AutobusApi.Application.Countries.Queries; using AutobusApi.Application.Countries.Queries.GetCountriesWithPagination; using AutobusApi.Application.Countries.Queries.GetCountry; using Microsoft.AspNetCore.Mvc; namespace AutobusApi.Api.Controllers; [Route("countries")] public class CountryController : BaseController { [HttpPost] public async Task Create([FromBody] CreateCountryCommand command, CancellationToken cancellationToken) { return await Mediator.Send(command, cancellationToken); } [HttpGet] public async Task> GetPage([FromQuery] GetCountriesWithPaginationQuery query, CancellationToken cancellationToken) { return await Mediator.Send(query, cancellationToken); } [HttpGet("{id}")] public async Task Get(int id, /* [FromQuery] GetCountryQuery query, */ CancellationToken cancellationToken) { var query = new GetCountryQuery() { Id = id }; return await Mediator.Send(query, cancellationToken); } [HttpPut] public async Task Update([FromBody] UpdateCountryCommand command, CancellationToken cancellationToken) { await Mediator.Send(command, cancellationToken); } [HttpDelete("{id}")] public async Task Delete(int id, /* [FromBody] DeleteCountryCommand command, */ CancellationToken cancellationToken) { var command = new DeleteCountryCommand() { Id = id }; await Mediator.Send(command, cancellationToken); } }