initial commit
This commit is contained in:
@@ -0,0 +1,39 @@
|
||||
using Indotalent.Infrastructure.Database;
|
||||
using MediatR;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace Indotalent.Features.Pipeline.LeadContact.Cqrs;
|
||||
|
||||
public class LeadContactLookupResponse
|
||||
{
|
||||
public List<LookupItem> Leads { get; set; } = new();
|
||||
}
|
||||
|
||||
public class LookupItem
|
||||
{
|
||||
public string? Id { get; set; }
|
||||
public string? Name { get; set; }
|
||||
}
|
||||
|
||||
public record GetLeadContactLookupQuery() : IRequest<LeadContactLookupResponse>;
|
||||
|
||||
public class GetLeadContactLookupHandler : IRequestHandler<GetLeadContactLookupQuery, LeadContactLookupResponse>
|
||||
{
|
||||
private readonly AppDbContext _context;
|
||||
|
||||
public GetLeadContactLookupHandler(AppDbContext context) => _context = context;
|
||||
|
||||
public async Task<LeadContactLookupResponse> Handle(GetLeadContactLookupQuery request, CancellationToken cancellationToken)
|
||||
{
|
||||
var response = new LeadContactLookupResponse();
|
||||
|
||||
response.Leads = await _context.Lead.AsNoTracking()
|
||||
.Select(x => new LookupItem
|
||||
{
|
||||
Id = x.Id,
|
||||
Name = x.Title
|
||||
}).ToListAsync(cancellationToken);
|
||||
|
||||
return response;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user