using Indotalent.Infrastructure.Database; using MediatR; using Microsoft.EntityFrameworkCore; namespace Indotalent.Features.Pipeline.LeadContact.Cqrs; public class GetLeadContactAvatarInfoResponse { public string Id { get; set; } = string.Empty; public string? FullName { get; set; } public string? AvatarName { get; set; } } public record GetLeadContactAvatarInfoQuery(string Id) : IRequest; public class GetLeadContactAvatarInfoHandler : IRequestHandler { private readonly AppDbContext _context; public GetLeadContactAvatarInfoHandler(AppDbContext context) { _context = context; } public async Task Handle(GetLeadContactAvatarInfoQuery request, CancellationToken cancellationToken) { var entity = await _context.LeadContact .AsNoTracking() .FirstOrDefaultAsync(x => x.Id == request.Id, cancellationToken); if (entity == null) return null; return new GetLeadContactAvatarInfoResponse { Id = entity.Id, FullName = entity.FullName, AvatarName = entity.AvatarName }; } }