initial commit
This commit is contained in:
@@ -0,0 +1,40 @@
|
||||
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<GetLeadContactAvatarInfoResponse?>;
|
||||
|
||||
public class GetLeadContactAvatarInfoHandler : IRequestHandler<GetLeadContactAvatarInfoQuery, GetLeadContactAvatarInfoResponse?>
|
||||
{
|
||||
private readonly AppDbContext _context;
|
||||
|
||||
public GetLeadContactAvatarInfoHandler(AppDbContext context)
|
||||
{
|
||||
_context = context;
|
||||
}
|
||||
|
||||
public async Task<GetLeadContactAvatarInfoResponse?> 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
|
||||
};
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user