using Application.Abstractions.Messaging; using Application.Abstractions.Data; using Application.Abstractions.Cache; using Microsoft.EntityFrameworkCore; namespace Application.Features.Api.Popup.Position.GetActive; public sealed class Handler(IAppDbContext db, ICacheService cache) : IQueryHandler { public async Task Handle(Query request, CancellationToken ct) { var cached = await cache.GetAsync(CacheKeys.PopupPositionActive, ct); if (cached is not null) { return cached; } var rows = await db.PopupPosition .AsNoTracking() .Where(c => c.IsActive) .OrderBy(c => c.ID) .Select(c => new Response.Row( c.ID, c.Code, c.Subject )) .ToListAsync(ct); var response = new Response(rows.Count, rows); await cache.SetAsync(CacheKeys.PopupPositionActive, response, ct); return response; } }