namespace Yes.Application.Admins.Themes { public record GetThemeFilesQuery(string Name) : IRequest>; public record GetThemeFilesQueryResponse( string FileName ); public class GetThemeFilesQueryHandler(IWebHostEnvironment env) : IRequestHandler> { private readonly IWebHostEnvironment _env = env; public async Task> Handle(GetThemeFilesQuery request, CancellationToken cancellationToken) { var themeName = request.Name; var themes = new List(); var themePath = Path.Combine(_env.ContentRootPath, "files", "themes", themeName); var allowedExtensions = new[] { ".liquid", ".css", ".js" }; var files = Directory.GetFiles(themePath, "*.*", SearchOption.AllDirectories).Where(file => allowedExtensions.Contains(Path.GetExtension(file).ToLowerInvariant())); themes = files.Select(x=>new GetThemeFilesQueryResponse(Path.GetRelativePath(themePath, x))).ToList(); return themes; } } }