Files
WebNovelPortal/DBConnection/Repositories/NovelRepository.cs
2022-07-14 19:31:53 -04:00

37 lines
971 B
C#

using DBConnection.Models;
using DBConnection.Repositories.Interfaces;
using Microsoft.EntityFrameworkCore;
namespace DBConnection.Repositories;
public class NovelRepository : BaseRepository<Novel>, INovelRepository
{
public NovelRepository(AppDbContext dbContext) : base(dbContext)
{
}
protected override IQueryable<Novel> GetAllIncludedQueryable()
{
return DbContext.Novels
.Include(i => i.Author)
.Include(i => i.Chapters)
.Include(i => i.Tags);
}
public async Task<Novel?> GetNovel(string url)
{
return await GetIncluded(i => i.Url == url);
}
public async Task<IEnumerable<Novel>> LookupNovelsByName(string name)
{
return await GetWhereIncluded(n => n.Title.Contains(name));
}
public async Task<IEnumerable<Novel>> LookupNovelsByTag(string tag)
{
return await GetWhereIncluded(n => n.Tags.Any(nt => nt.TagValue.Contains(tag)));
}
}