GetHandler.cs 1.2 KB

123456789101112131415161718192021222324252627282930313233
  1. using Application.Abstractions.Messaging;
  2. using Application.Abstractions.Data;
  3. using Microsoft.EntityFrameworkCore;
  4. namespace Application.Features.Admin.Member.List.Approve;
  5. public sealed class GetHandler(IAppDbContext db) : IQueryHandler<Query, Response>
  6. {
  7. public async Task<Response> Handle(Query request, CancellationToken ct)
  8. {
  9. var member = await db.Member.AsNoTracking().Include(x => x.MemberApprove).FirstOrDefaultAsync(x => x.ID == request.MemberID, ct);
  10. if (member is null)
  11. {
  12. throw new KeyNotFoundException("회원을 찾을 수 없습니다.");
  13. }
  14. var approve = member.MemberApprove;
  15. return new Response
  16. {
  17. MemberID = member.ID,
  18. IsReceiveSMS = approve.IsReceiveSMS,
  19. ReceiveSMSConsentAt = approve.ReceiveSMSConsentAt,
  20. IsReceiveEmail = approve.IsReceiveEmail,
  21. ReceiveEmailConsentAt = approve.ReceiveEmailConsentAt,
  22. IsReceiveNote = approve.IsReceiveNote,
  23. ReceiveNoteConsentAt = approve.ReceiveNoteConsentAt,
  24. IsDisclosureInvest = approve.IsDisclosureInvest,
  25. DisclosureInvestConsentAt = approve.DisclosureInvestConsentAt
  26. };
  27. }
  28. }