forked from ddrilling/AsbCloudServer
4767335900
1. Поправил тесты 2. Поправил сервис, репозиторий и контроллер. Сделал небольшой рефакторинг
35 lines
917 B
C#
35 lines
917 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 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>();
|
|
}
|
|
}
|