DD.WellWorkover.Cloud/AsbCloudInfrastructure/Repository/HelpPageRepository.cs
Дмитрий Степанов a0720e9270 Рефакторинг
1. Выпилил лишнюю логику
2. Прокинул IConfiguration в HelpPageService
3. Поправил миграции
4. Поправил тесты
2023-06-29 16:31:37 +05:00

35 lines
925 B
C#

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 urlPage,
int idCategory,
CancellationToken cancellationToken)
{
var helpPage = await dbSet.AsNoTracking()
.SingleOrDefaultAsync(x =>
x.UrlPage == urlPage &&
x.IdCategory == idCategory,
cancellationToken);
if (helpPage is null)
return null;
return helpPage.Adapt<HelpPageDto>();
}
}