using Brizco.Core.CoreServices.ReportServices.Commands; using MediatR; namespace Brizco.Api.Controllers; public class ReportController : ICarterModule { public void AddRoutes(IEndpointRouteBuilder app) { var group = app.NewVersionedApi("Report") .MapGroup("api/report"); group.MapGet("task", GetTasksReportAsync) .WithDisplayName("Get Tasks Report") .HasApiVersion(1.0); group.MapGet("shift/plan/{shiftPLanId}", GetShiftPlanReportAsync) .WithDisplayName("Get ShiftPlan Report") .HasApiVersion(1.0); } public async Task GetTasksReportAsync([FromServices]IMediator mediator,CancellationToken cancellationToken) { var file = await mediator.Send(new TaskReportCommand(),cancellationToken); string fileName = $"TaskReport_{DateTime.Now:yyyy-MM-dd}.xlsx"; return TypedResults.File(file, "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", fileName); } public async Task GetShiftPlanReportAsync(Guid shiftPLanId,[FromServices] IMediator mediator, CancellationToken cancellationToken) { var file = await mediator.Send(new ShiftPlanReportCommand(ShiftPlanId: shiftPLanId), cancellationToken); string fileName = $"ShiftPlanReport_{DateTime.Now:yyyy-MM-dd}.xlsx"; return TypedResults.File(file, "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", fileName); } }