Handler.cs 982 B

12345678910111213141516171819202122232425262728
  1. using Application.Abstractions.Data;
  2. using Application.Abstractions.Messaging;
  3. using Microsoft.EntityFrameworkCore;
  4. namespace Application.Features.Api.Studio.Dashboard.GetDashboard;
  5. internal sealed class Handler(IAppDbContext db) : IQueryHandler<Query, Response>
  6. {
  7. private static readonly Response Empty = new(null);
  8. public async Task<Response> Handle(Query request, CancellationToken ct)
  9. {
  10. // ── 채널 정보 ──
  11. var channel = await db.Channel.AsNoTracking().Where(c => c.MemberID == request.MemberID && c.IsActive).Select(c => new { c.ID, c.SID, c.Name, c.ThumbnailUrl, c.IsVerified, c.SubscriberCount }).FirstOrDefaultAsync(ct);
  12. if (channel is null)
  13. {
  14. return Empty;
  15. }
  16. var channelInfo = new ChannelInfo(
  17. channel.ID, channel.SID, channel.Name,
  18. channel.ThumbnailUrl, channel.IsVerified, channel.SubscriberCount
  19. );
  20. return new Response(channelInfo);
  21. }
  22. }