using System.Linq; using xModels.Dtos; using System.Threading; using xCommons.Extensions; using xAiModels.Models.Dtos; using System.Threading.Tasks; using xAiModels.Models.Entities; using System.Collections.Generic; using xIdentityService.Interfaces; using xAiModels.Interfaces.Enrichers; namespace xAiModels.Providers.Enrichers { public class XAiMcpServerEnricher : IXAiMcpServerEnricher { private readonly IXPersonService personService; public XAiMcpServerEnricher( IXPersonService personService ) { this.personService = personService; } public virtual async Task Enrich( XAiMcpServer source, CancellationToken cancellationToken = default ) { // var result = source.MapConvert(); result = await Enrich( source: result, cancellationToken: cancellationToken ); // return result; } public virtual async Task Enrich( XAiMcpServerDto source, CancellationToken cancellationToken = default ) { // XPersonDto owner = null; if (!source.OwnerId.IsNullOrEmpty()) { owner = await personService.GetPerson(source.OwnerId); } // var result = source.MapConvert(); result.Owner = owner; // return result; } public virtual async Task> EnrichRange( IEnumerable sources, CancellationToken cancellationToken = default ) { var tasks = sources.Select(x => Enrich(x, cancellationToken)); return await Task.WhenAll(tasks); } public virtual async Task> EnrichRange( IEnumerable sources, CancellationToken cancellationToken = default ) { var tasks = sources.Select(x => Enrich(x, cancellationToken)); return await Task.WhenAll(tasks); } } }