feat: refactor week number handling to use WeekDefinitionId across multiple entities and queries

This commit is contained in:
masoodafar-web
2025-12-19 10:41:22 +03:30
parent 3cb95dc349
commit 8b784101be
83 changed files with 17592 additions and 566 deletions
@@ -5,10 +5,14 @@ namespace CMSMicroservice.Application.CommissionCQ.Queries.GetWorkerStatus;
public class GetWorkerStatusQueryHandler : IRequestHandler<GetWorkerStatusQuery, GetWorkerStatusResponseDto>
{
private readonly IApplicationDbContext _context;
private readonly IWeekDefinitionRepository _weekDefinitionRepository;
public GetWorkerStatusQueryHandler(IApplicationDbContext context)
public GetWorkerStatusQueryHandler(
IApplicationDbContext context,
IWeekDefinitionRepository weekDefinitionRepository)
{
_context = context;
_weekDefinitionRepository = weekDefinitionRepository;
}
public async Task<GetWorkerStatusResponseDto> Handle(
@@ -19,13 +23,19 @@ public class GetWorkerStatusQueryHandler : IRequestHandler<GetWorkerStatusQuery,
// فعلاً mock data برمی‌گرداند
await Task.CompletedTask;
var currentWeek = _weekDefinitionRepository.GetCurrentWeek();
var currentWeekNumber = currentWeek != null
? $"{currentWeek.GregorianYear}-W{currentWeek.GregorianWeekNumber:D2}"
: null;
return new GetWorkerStatusResponseDto
{
IsRunning = false,
IsEnabled = true,
CurrentExecutionId = null,
CurrentWeekNumber = null,
CurrentWeekNumber = currentWeekNumber,
CurrentWeekDisplayName = currentWeek?.DisplayName,
CurrentStep = "Idle",
LastRunAt = DateTime.Now.AddHours(-24),
NextScheduledRun = DateTime.Now.AddDays(7),