23 lines
708 B
C#
23 lines
708 B
C#
|
|
using SIGCM2.Application.Abstractions;
|
||
|
|
using SIGCM2.Application.Abstractions.Persistence;
|
||
|
|
using SIGCM2.Application.Rubros.Common;
|
||
|
|
using SIGCM2.Application.Rubros.Dtos;
|
||
|
|
|
||
|
|
namespace SIGCM2.Application.Rubros.GetTree;
|
||
|
|
|
||
|
|
public sealed class GetRubroTreeQueryHandler : ICommandHandler<GetRubroTreeQuery, IReadOnlyList<RubroTreeNodeDto>>
|
||
|
|
{
|
||
|
|
private readonly IRubroRepository _repo;
|
||
|
|
|
||
|
|
public GetRubroTreeQueryHandler(IRubroRepository repo)
|
||
|
|
{
|
||
|
|
_repo = repo;
|
||
|
|
}
|
||
|
|
|
||
|
|
public async Task<IReadOnlyList<RubroTreeNodeDto>> Handle(GetRubroTreeQuery query)
|
||
|
|
{
|
||
|
|
var all = await _repo.GetAllAsync(query.IncluirInactivos);
|
||
|
|
return RubroTreeBuilder.Build(all, query.IncluirInactivos);
|
||
|
|
}
|
||
|
|
}
|