using ErsatzTV.Application.Graphics; using ErsatzTV.Core.Api.Graphics; using MediatR; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Mvc; namespace ErsatzTV.Controllers.Api; [ApiController] public class GraphicsElementController(IMediator mediator) : ControllerBase { [HttpGet("/api/graphics-elements", Name = "GetGraphicsElements")] [Tags("Graphics Elements")] [EndpointSummary("Get all graphics elements")] [EndpointDescription( "Returns all graphics elements. Pass refresh=true to first re-sync the on-disk graphics element " + "definitions into the database (matching the legacy Blazor behavior) so newly added files appear.")] [EndpointGroupName("general")] [ProducesResponseType(typeof(List), StatusCodes.Status200OK)] public async Task> GetAll( [FromQuery] bool refresh, CancellationToken cancellationToken) { if (refresh) { await mediator.Send(new RefreshGraphicsElements(), cancellationToken); } return await mediator.Send(new GetAllGraphicsElementsForApi(), cancellationToken); } }