WebApi + ClientApp, GraphQL, Reflection

This commit is contained in:
Boris Milašinović
2026-05-06 20:55:05 +02:00
parent 8f7c704a90
commit 4fb3de19f6
196 changed files with 10395 additions and 0 deletions

View File

@@ -0,0 +1,37 @@
using Events.WebAPI.Contract.DTOs;
using Events.WebAPI.Contract.LookupQueries;
using Events.WebAPI.Handlers.EF.Data.Postgres;
using MediatR;
using Microsoft.EntityFrameworkCore;
namespace Events.WebAPI.Handlers.EF.QueryHandlers;
public class CountriesLookupQueryHandler : IRequestHandler<LookupCountryQuery, List<IdName<string>>>
{
private readonly EventsContext ctx;
public CountriesLookupQueryHandler(EventsContext ctx)
{
this.ctx = ctx;
}
public async Task<List<IdName<string>>> Handle(LookupCountryQuery request, CancellationToken cancellationToken)
{
var query = ctx.Countries.AsNoTracking();
if (!string.IsNullOrWhiteSpace(request.Text))
{
string text = request.Text.Trim();
query = query.Where(c => Microsoft.EntityFrameworkCore.EF.Functions.ILike(c.Name, $"%{text}%"));
}
return await query
.OrderBy(c => c.Name)
.Select(c => new IdName<string>
{
Id = c.Code,
Name = c.Name
})
.ToListAsync(cancellationToken);
}
}