using AutobusApi.Application.Common.Models; using AutobusApi.Application.Regions.Commands.CreateRegion; using AutobusApi.Application.Regions.Commands.DeleteRegion; using AutobusApi.Application.Regions.Commands.UpdateRegion; using AutobusApi.Application.Regions.Queries; using AutobusApi.Application.Regions.Queries.GetRegionsWithPagination; using AutobusApi.Application.Regions.Queries.GetRegion; using Microsoft.AspNetCore.Mvc; namespace AutobusApi.Api.Controllers; [Route("regions")] public class RegionController : BaseController { [HttpPost] public async Task Create([FromBody] CreateRegionCommand command, CancellationToken cancellationToken) { return await Mediator.Send(command, cancellationToken); } [HttpGet] public async Task> GetPage([FromQuery] GetRegionsWithPaginationQuery query, CancellationToken cancellationToken) { return await Mediator.Send(query, cancellationToken); } [HttpGet("{id}")] public async Task Get(int id, /* [FromQuery] GetRegionQuery query, */ CancellationToken cancellationToken) { var query = new GetRegionQuery() { Id = id }; return await Mediator.Send(query, cancellationToken); } [HttpPut] public async Task Update([FromBody] UpdateRegionCommand command, CancellationToken cancellationToken) { await Mediator.Send(command, cancellationToken); } [HttpDelete("{id}")] public async Task Delete(int id, /* [FromBody] DeleteRegionCommand command, */ CancellationToken cancellationToken) { var command = new DeleteRegionCommand() { Id = id }; await Mediator.Send(command, cancellationToken); } }