mirror of https://github.com/ErsatzTV/ErsatzTV.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
24 lines
896 B
24 lines
896 B
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<TvContext> dbContextFactory) : IGraphicsElementRepository |
|
{ |
|
public async Task<Option<GraphicsElement>> 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); |
|
} |
|
}
|
|
|