25 lines
594 B
C#
25 lines
594 B
C#
using System.Threading;
|
|
using System.Linq;
|
|
using System.Threading.Tasks;
|
|
using MediatR;
|
|
|
|
namespace HN.Application
|
|
{
|
|
public sealed class ListLinksQueryHandler : IRequestHandler<ListLinksQuery, LinkDTO[]>
|
|
{
|
|
private readonly IDbContext _context;
|
|
|
|
public ListLinksQueryHandler(IDbContext context)
|
|
{
|
|
_context = context;
|
|
}
|
|
|
|
public Task<LinkDTO[]> Handle(ListLinksQuery request, CancellationToken cancellationToken)
|
|
{
|
|
var links = from link in _context.Links
|
|
select new LinkDTO(link);
|
|
|
|
return Task.FromResult(links.ToArray());
|
|
}
|
|
}
|
|
} |