using Application.Abstractions.Data; using Application.Abstractions.Messaging; using Microsoft.EntityFrameworkCore; namespace Application.Features.Api.ChannelTitle.GetChannelTitles; internal sealed class Handler(IAppDbContext db) : IQueryHandler { public async Task Handle(Query request, CancellationToken ct) { var query = db.ChannelTitle.AsNoTracking().Where(t => t.ChannelID == request.ChannelID); if (!request.IncludeInactive) { query = query.Where(t => t.IsActive); } var titles = await query.OrderBy(t => t.SortOrder).ThenBy(t => t.MinAmount) .Select(t => new TitleItem( t.ID, t.ChannelID, t.Name, t.Description, t.MinAmount, t.Color, t.IconUrl, t.SortOrder, t.IsActive )) .ToListAsync(ct); return new Response(titles); } }