using MediatR; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; using Tnsu.ApprovalRoute.Api.Common; using Tnsu.ApprovalRoute.Application.TemplateRouteSteps; namespace Tnsu.ApprovalRoute.Api.Controllers; [ApiController] [Authorize] [Route("api/template-routes/{routeId:guid}/steps")] public sealed class TemplateRouteStepsController(ISender mediator) : ControllerBase { [HttpGet] public async Task List(Guid routeId, CancellationToken ct) => (await mediator.Send(new ListTemplateRouteStepsQuery(routeId), ct)).ToActionResult(); [HttpGet("{id:guid}")] public async Task Get(Guid routeId, Guid id, CancellationToken ct) => (await mediator.Send(new GetTemplateRouteStepQuery(routeId, id), ct)).ToActionResult(); [HttpPost] public async Task Create(Guid routeId, CreateTemplateRouteStepRequest body, CancellationToken ct) => (await mediator.Send(new CreateTemplateRouteStepCommand(routeId, body), ct)).ToActionResult(); [HttpPut("{id:guid}")] public async Task Update(Guid routeId, Guid id, UpdateTemplateRouteStepRequest body, CancellationToken ct) => (await mediator.Send(new UpdateTemplateRouteStepCommand(routeId, id, body), ct)).ToActionResult(); [HttpDelete("{id:guid}")] public async Task Delete(Guid routeId, Guid id, CancellationToken ct) => (await mediator.Send(new DeleteTemplateRouteStepCommand(routeId, id), ct)).ToActionResult(); }