using System.Linq; using System.Threading; using xCommons.Extensions; using xIdentityModels.Dtos; using System.Threading.Tasks; using xIdentityModels.Models; using System.Collections.Generic; using Microsoft.EntityFrameworkCore; namespace xIds.Providers { public partial class XApplicationProvider { // #region Enrichers ... /// /// Enrich Api Key ... /// /// /// /// public async Task EnrichAsync( XApiKey source, CancellationToken cancellationToken = default ) { // var result = source.MapConvert(); result = await EnrichAsync( source: result, cancellationToken: cancellationToken ); // return result; } /// /// Enrich Api Key ... /// /// /// /// public async Task EnrichAsync( XApiKeyDto source, CancellationToken cancellationToken = default ) { // if ( !source.IsNullOrDefault() && !source.Application.IsNullOrDefault() ) { // var application = await dbContext.Applications .FirstOrDefaultAsync( x => x.Id == source.ApplicationId, cancellationToken: cancellationToken ); if (!application.IsNullOrDefault()) { // var dto = await EnrichAsync( source: application, cancellationToken: cancellationToken ); if (!dto.IsNullOrDefault()) { source.Application = dto; } } } // return source; } /// /// Enrich Api Key Usage ... /// /// /// /// public async Task EnrichAsync( XApiKeyUsage source, CancellationToken cancellationToken = default ) { // var result = source.MapConvert(); result = await EnrichAsync( source: result, cancellationToken: cancellationToken ); // return result; } /// /// Enrich Application ... /// /// /// /// public async Task EnrichAsync( XApplication source, CancellationToken cancellationToken = default ) { // var result = source.MapConvert(); result = await EnrichAsync( source: result, cancellationToken: cancellationToken ); // return result; } /// /// Enrich Api Key Usage ... /// /// /// /// public async Task EnrichAsync( XApiKeyUsageDto source, CancellationToken cancellationToken = default ) { // // There is not any Additional Enrichment ... var result = await Task.FromResult(source); return result; } /// /// Enrich Application ... /// /// /// /// public async Task EnrichAsync( XApplicationDto source, CancellationToken cancellationToken = default ) { // if ( !source.IsNullOrDefault() && !source.OwnerId.IsNullOrEmpty() ) { // var owner = await GetOwner(source.OwnerId); if (!owner.IsNullOrDefault()) { source.Owner = owner; } } // return source; } /// /// Enrich a Collection of Api Key(s) ... /// /// /// /// public async Task> EnrichRangeAsync( IEnumerable sources, CancellationToken cancellationToken = default ) { // var tasks = sources .Select(s => EnrichAsync(s, cancellationToken)); // var result = await Task.WhenAll(tasks); // return result; } /// /// Enrich a Collection of Api Key(s) ... /// /// /// /// public async Task> EnrichRangeAsync( IEnumerable sources, CancellationToken cancellationToken = default ) { // var tasks = sources .Select(s => EnrichAsync(s, cancellationToken)); // var result = await Task.WhenAll(tasks); // return result; } /// /// Enrich a Collection of Api Key Usage(s) ... /// /// /// /// public async Task> EnrichRangeAsync( IEnumerable sources, CancellationToken cancellationToken = default ) { // var tasks = sources .Select(s => EnrichAsync(s, cancellationToken)); // var result = await Task.WhenAll(tasks); // return result; } /// /// Enrich a Collection of Application(s) ... /// /// /// /// public async Task> EnrichRangeAsync( IEnumerable sources, CancellationToken cancellationToken = default ) { // var tasks = sources .Select(s => EnrichAsync(s, cancellationToken)); // var result = await Task.WhenAll(tasks); // return result; } /// /// Enrich a Collection of Api Key Usage(s) ... /// /// /// /// public async Task> EnrichRangeAsync( IEnumerable sources, CancellationToken cancellationToken = default ) { // var tasks = sources .Select(s => EnrichAsync(s, cancellationToken)); // var result = await Task.WhenAll(tasks); // return result; } /// /// Enrich a Collection of Application(s) ... /// /// /// /// public async Task> EnrichRangeAsync( IEnumerable sources, CancellationToken cancellationToken = default ) { // var tasks = sources .Select(s => EnrichAsync(s, cancellationToken)); // var result = await Task.WhenAll(tasks); // return result; } #endregion } }