namespace Brizco.Repository.Handlers.Sections; public class GetSectionsQueryHandler(IRepositoryWrapper repositoryWrapper, ICurrentUserService currentUserService) : IRequestHandler> { public async Task> Handle(GetSectionsQuery request, CancellationToken cancellationToken) { if (currentUserService.ComplexId == null) throw new AppException("ComplexId is null", ApiResultStatusCode.NotFound); if (!Guid.TryParse(currentUserService.ComplexId, out Guid complexId)) throw new AppException("ComplexId is wrong", ApiResultStatusCode.NotFound); var shifts = await repositoryWrapper.SetRepository
().TableNoTracking .Where(s=>s.ComplexId==complexId) .OrderByDescending(s => s.CreatedAt) .Skip(request.Page * 15).Take(15) .Select(SectionMapper.ProjectToSDto) .ToListAsync(cancellationToken); return shifts; } }