using AutobusApi.Application.Common.Models; using AutobusApi.Application.Addresses.Commands.CreateAddress; using AutobusApi.Application.Addresses.Commands.DeleteAddress; using AutobusApi.Application.Addresses.Commands.UpdateAddress; using AutobusApi.Application.Addresses.Queries; using AutobusApi.Application.Addresses.Queries.GetAddressesWithPagination; using AutobusApi.Application.Addresses.Queries.GetAddress; using Microsoft.AspNetCore.Mvc; namespace AutobusApi.Api.Controllers; [Route("addresses")] public class AddressController : BaseController { [HttpPost] public async Task Create([FromBody] CreateAddressCommand command, CancellationToken cancellationToken) { return await Mediator.Send(command, cancellationToken); } [HttpGet] public async Task> GetPage([FromQuery] GetAddressesWithPaginationQuery query, CancellationToken cancellationToken) { return await Mediator.Send(query, cancellationToken); } [HttpGet("{id}")] public async Task Get(int id, /* [FromQuery] GetAddressQuery query, */ CancellationToken cancellationToken) { var query = new GetAddressQuery() { Id = id }; return await Mediator.Send(query, cancellationToken); } [HttpPut] public async Task Update([FromBody] UpdateAddressCommand command, CancellationToken cancellationToken) { await Mediator.Send(command, cancellationToken); } [HttpDelete("{id}")] public async Task Delete(int id, /* [FromBody] DeleteAddressCommand command, */ CancellationToken cancellationToken) { var command = new DeleteAddressCommand() { Id = id }; await Mediator.Send(command, cancellationToken); } }