DD.WellWorkover.Cloud/AsbCloudInfrastructure/Repository/HelpPageRepository.cs

35 lines
914 B
C#
Raw Permalink Normal View History

using AsbCloudApp.Data;
using AsbCloudApp.Repositories;
using AsbCloudDb.Model;
using Mapster;
using Microsoft.EntityFrameworkCore;
using System.Threading;
using System.Threading.Tasks;
namespace AsbCloudInfrastructure.Repository;
public class HelpPageRepository : CrudRepositoryBase<HelpPageDto, HelpPage>,
IHelpPageRepository
{
public HelpPageRepository(IAsbCloudDbContext context)
: base(context)
{
}
public async Task<HelpPageDto?> GetOrDefaultByUrlPageAndIdCategoryAsync(string key,
int idCategory,
CancellationToken cancellationToken)
{
var helpPage = await dbSet.AsNoTracking()
.SingleOrDefaultAsync(x =>
x.UrlPage == key &&
x.IdCategory == idCategory,
cancellationToken);
if (helpPage is null)
return null;
return helpPage.Adapt<HelpPageDto>();
}
}