using Application.Abstractions.Crypto; using Application.Abstractions.Data; using Application.Abstractions.Messaging; using Microsoft.EntityFrameworkCore; namespace Application.Features.Api.MyPage.Address.List; public sealed class Handler(IAppDbContext db, IFieldEncryptor encryptor) : IQueryHandler { public async Task Handle(Query request, CancellationToken ct) { var addresses = await db.MemberAddress .AsNoTracking() .Where(a => a.MemberID == request.MemberID) .OrderByDescending(a => a.IsDefault) .ThenByDescending(a => a.ID) .ToListAsync(ct); var list = addresses.Select(a => new Response.Row( ID: a.ID, IsDefault: a.IsDefault, RecipientName: encryptor.Decrypt(a.RecipientName_Encrypted, a.KeyVersion), Phone: encryptor.Decrypt(a.Phone_Encrypted, a.KeyVersion), ZipCode: a.ZipCode, Address1: encryptor.Decrypt(a.Address1_Encrypted, a.KeyVersion), Address2: encryptor.Decrypt(a.Address2_Encrypted, a.KeyVersion), CreatedAt: a.CreatedAt, UpdatedAt: a.UpdatedAt )).ToList(); return new Response(list); } }