using AutobusApi.Application.Common.Models; using AutobusApi.Application.Companies.Commands.CreateCompany; using AutobusApi.Application.Companies.Commands.DeleteCompany; using AutobusApi.Application.Companies.Commands.UpdateCompany; using AutobusApi.Application.Companies.Queries; using AutobusApi.Application.Companies.Queries.GetCompaniesWithPagination; using AutobusApi.Application.Companies.Queries.GetCompany; using Microsoft.AspNetCore.Mvc; namespace AutobusApi.Api.Controllers; [Route("companies")] public class CompanyController : BaseController { [HttpPost] public async Task Create([FromBody] CreateCompanyCommand command, CancellationToken cancellationToken) { return await Mediator.Send(command, cancellationToken); } [HttpGet] public async Task> GetPage([FromQuery] GetCompaniesWithPaginationQuery query, CancellationToken cancellationToken) { return await Mediator.Send(query, cancellationToken); } [HttpGet("{id}")] public async Task Get(int id, /* [FromQuery] GetCompanyQuery query, */ CancellationToken cancellationToken) { var query = new GetCompanyQuery() { Id = id }; return await Mediator.Send(query, cancellationToken); } [HttpPut] public async Task Update([FromBody] UpdateCompanyCommand command, CancellationToken cancellationToken) { await Mediator.Send(command, cancellationToken); } [HttpDelete("{id}")] public async Task Delete(int id, /* [FromBody] DeleteCompanyCommand command, */ CancellationToken cancellationToken) { var command = new DeleteCompanyCommand() { Id = id }; await Mediator.Send(command, cancellationToken); } }