using ErsatzTV.Core; using ErsatzTV.Core.Domain; using ErsatzTV.Core.Interfaces.Repositories; using ErsatzTV.Infrastructure.Extensions; using Microsoft.EntityFrameworkCore; namespace ErsatzTV.Infrastructure.Data.Repositories; public class GraphicsElementRepository(IDbContextFactory dbContextFactory) : IGraphicsElementRepository { public async Task> GetGraphicsElementByPath(string path) { await using TvContext dbContext = await dbContextFactory.CreateDbContextAsync(); if (!path.StartsWith(FileSystemLayout.GraphicsElementsTemplatesFolder, StringComparison.Ordinal)) { path = Path.Combine(FileSystemLayout.GraphicsElementsTemplatesFolder, path); } return await dbContext.GraphicsElements .AsNoTracking() .SelectOneAsync(ge => ge.Path, ge => ge.Path == path); } }