2025-11-29 04:32:17 +03:30
|
|
|
namespace CMSMicroservice.Application.CommissionCQ.Queries.GetWeeklyCommissionPool;
|
|
|
|
|
|
|
|
|
|
public class GetWeeklyCommissionPoolQueryHandler : IRequestHandler<GetWeeklyCommissionPoolQuery, WeeklyCommissionPoolDto?>
|
|
|
|
|
{
|
|
|
|
|
private readonly IApplicationDbContext _context;
|
|
|
|
|
|
|
|
|
|
public GetWeeklyCommissionPoolQueryHandler(IApplicationDbContext context)
|
|
|
|
|
{
|
|
|
|
|
_context = context;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public async Task<WeeklyCommissionPoolDto?> Handle(GetWeeklyCommissionPoolQuery request, CancellationToken cancellationToken)
|
|
|
|
|
{
|
|
|
|
|
var pool = await _context.WeeklyCommissionPools
|
|
|
|
|
.AsNoTracking()
|
|
|
|
|
.Where(x => x.WeekNumber == request.WeekNumber)
|
|
|
|
|
.Select(x => new WeeklyCommissionPoolDto
|
|
|
|
|
{
|
|
|
|
|
Id = x.Id,
|
|
|
|
|
WeekNumber = x.WeekNumber,
|
|
|
|
|
TotalPoolAmount = x.TotalPoolAmount,
|
|
|
|
|
TotalBalances = x.TotalBalances,
|
|
|
|
|
ValuePerBalance = x.ValuePerBalance,
|
|
|
|
|
IsCalculated = x.IsCalculated,
|
|
|
|
|
CalculatedAt = x.CalculatedAt,
|
|
|
|
|
Created = x.Created
|
|
|
|
|
})
|
|
|
|
|
.FirstOrDefaultAsync(cancellationToken);
|
|
|
|
|
|
2025-12-12 04:22:16 +03:30
|
|
|
return pool??new WeeklyCommissionPoolDto();
|
2025-11-29 04:32:17 +03:30
|
|
|
}
|
|
|
|
|
}
|