using AutobusApi.Application.Common.Models; using AutobusApi.Application.Cities.Commands.CreateCity; using AutobusApi.Application.Cities.Commands.DeleteCity; using AutobusApi.Application.Cities.Commands.UpdateCity; using AutobusApi.Application.Cities.Queries; using AutobusApi.Application.Cities.Queries.GetCitiesWithPagination; using AutobusApi.Application.Cities.Queries.GetCity; using Microsoft.AspNetCore.Mvc; namespace AutobusApi.Api.Controllers; [Route("cities")] public class CityController : BaseController { [HttpPost] public async Task Create([FromBody] CreateCityCommand command, CancellationToken cancellationToken) { return await Mediator.Send(command, cancellationToken); } [HttpGet] public async Task> GetPage([FromQuery] GetCitiesWithPaginationQuery query, CancellationToken cancellationToken) { return await Mediator.Send(query, cancellationToken); } [HttpGet("{id}")] public async Task Get(int id, /* [FromQuery] GetCityQuery query, */ CancellationToken cancellationToken) { var query = new GetCityQuery() { Id = id }; return await Mediator.Send(query, cancellationToken); } [HttpPut] public async Task Update([FromBody] UpdateCityCommand command, CancellationToken cancellationToken) { await Mediator.Send(command, cancellationToken); } [HttpDelete("{id}")] public async Task Delete(int id, /* [FromBody] DeleteCityCommand command, */ CancellationToken cancellationToken) { var command = new DeleteCityCommand() { Id = id }; await Mediator.Send(command, cancellationToken); } }