namespace Yes.Application.Admins.Themes { public record GetThemeFileQuery(string ThemeName, string FileName) : IRequest; public record GetThemeFileQueryResponse( string Content ); public class GetThemeFileQueryHandler(IOptionsMonitor options, IMapper mapper, IWebHostEnvironment env) : IRequestHandler { private readonly BlogSettings _settings = options.CurrentValue; private readonly IMapper _mapper = mapper; private readonly IWebHostEnvironment _env = env; public async Task Handle(GetThemeFileQuery request, CancellationToken cancellationToken) { var themeName = request.ThemeName; var fileName = request.FileName; var themes = new List(); var filePath = Path.Combine(_env.ContentRootPath, "files", "themes", themeName, fileName); var content = ""; if (File.Exists(filePath)) { content = File.ReadAllText(filePath); } return new GetThemeFileQueryResponse(content); } } }