namespace Brizco.Repository.Handlers.Activities;

public class GetShiftPlanActivitiesQueryHandler(IRepositoryWrapper repositoryWrapper) : IRequestHandler<GetShiftPlanActivitiesQuery, List<ActivitySDto>>
{
    public async Task<List<ActivitySDto>> Handle(GetShiftPlanActivitiesQuery request, CancellationToken cancellationToken)
    {
        var activities = await repositoryWrapper.SetRepository<Domain.Entities.Tasks.Activity>()
            .TableNoTracking
            .Where(a => a.ShiftPlanId == request.ShiftPlanId)
            .Select(ActivityMapper.ProjectToSDto)
            .ToListAsync(cancellationToken);

        return activities;
    }
}