Compare commits
1
Commits
8e1566310c
...
831c7004a8
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
831c7004a8 |
@@ -1,10 +1,223 @@
|
|||||||
using System;
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Linq.Expressions;
|
||||||
|
using System.Threading;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using Microsoft.EntityFrameworkCore.Query;
|
||||||
using xAiModels.Models.Dtos;
|
using xAiModels.Models.Dtos;
|
||||||
using xAiModels.Models.Entities;
|
using xAiModels.Models.Entities;
|
||||||
using xDataService.Interfaces;
|
using xDataService.Interfaces;
|
||||||
|
using xModels.Dtos;
|
||||||
|
|
||||||
namespace xAiModels.Interfaces.Dtos
|
namespace xAiModels.Interfaces.Dtos
|
||||||
{
|
{
|
||||||
public interface IXAiProjectRepositoryService : IXBaseRepositoryService<XAiProject, XAiProjectDto, Guid>
|
public interface IXAiProjectRepositoryService : IXBaseRepositoryService<XAiProject, XAiProjectDto, Guid>
|
||||||
{ }
|
{
|
||||||
|
|
||||||
|
//
|
||||||
|
#region Actions ...
|
||||||
|
//
|
||||||
|
#region Add ...
|
||||||
|
/// <summary>
|
||||||
|
/// add a new Dto ...
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="item"></param>
|
||||||
|
/// <param name="saveChanges"></param>
|
||||||
|
/// <param name="fillConversations"></param>
|
||||||
|
/// <param name="cancellationToken"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
Task<XAiProjectDto> AddAsync(
|
||||||
|
XAiProjectDto item,
|
||||||
|
bool saveChanges = true,
|
||||||
|
bool fillConversations = true,
|
||||||
|
CancellationToken cancellationToken = default
|
||||||
|
);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// add or update a Dto (add if not exists/update if exists) ...
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="item"></param>
|
||||||
|
/// <param name="saveChanges"></param>
|
||||||
|
/// <param name="fillConversations"></param>
|
||||||
|
/// <param name="cancellationToken"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
Task<XAiProjectDto> AddOrUpdateAsync(
|
||||||
|
XAiProjectDto item,
|
||||||
|
bool saveChanges = true,
|
||||||
|
bool fillConversations = true,
|
||||||
|
CancellationToken cancellationToken = default
|
||||||
|
);
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
//
|
||||||
|
#region Update ...
|
||||||
|
/// <summary>
|
||||||
|
/// Update an Dto values ...
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="id"></param>
|
||||||
|
/// <param name="item"></param>
|
||||||
|
/// <param name="saveChanges"></param>
|
||||||
|
/// <param name="fillConversations"></param>
|
||||||
|
/// <param name="cancellationToken"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
Task<XAiProjectDto> UpdateAsync(
|
||||||
|
Guid id,
|
||||||
|
XAiProjectDto item,
|
||||||
|
bool saveChanges = true,
|
||||||
|
bool fillConversations = true,
|
||||||
|
CancellationToken cancellationToken = default
|
||||||
|
);
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
//
|
||||||
|
#region Remove ...
|
||||||
|
/// <summary>
|
||||||
|
/// remove an Dto by it's Id ...
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="id"></param>
|
||||||
|
/// <param name="softDelete"></param>
|
||||||
|
/// <param name="saveChanges"></param>
|
||||||
|
/// <param name="fillConversations"></param>
|
||||||
|
/// <param name="cancellationToken"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
Task<XAiProjectDto> RemoveAsync(
|
||||||
|
Guid id,
|
||||||
|
bool softDelete = false,
|
||||||
|
bool saveChanges = true,
|
||||||
|
bool fillConversations = true,
|
||||||
|
CancellationToken cancellationToken = default
|
||||||
|
);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// remove an Dto ...
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="item"></param>
|
||||||
|
/// <param name="softDelete"></param>
|
||||||
|
/// <param name="saveChanges"></param>
|
||||||
|
/// <param name="fillConversations"></param>
|
||||||
|
/// <param name="cancellationToken"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
Task<XAiProjectDto> RemoveAsync(
|
||||||
|
XAiProjectDto item,
|
||||||
|
bool softDelete = false,
|
||||||
|
bool saveChanges = true,
|
||||||
|
bool fillConversations = true,
|
||||||
|
CancellationToken cancellationToken = default
|
||||||
|
);
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
//
|
||||||
|
#region Retrieve ...
|
||||||
|
/// <summary>
|
||||||
|
/// retrieve an Dto by it's Id ...
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="id"></param>
|
||||||
|
/// <param name="ignoreSoftDeleteds"></param>
|
||||||
|
/// <param name="includeBuilder"></param>
|
||||||
|
/// <param name="fillConversations"></param>
|
||||||
|
/// <param name="cancellationToken"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
Task<XAiProjectDto> GetAsync(
|
||||||
|
Guid id,
|
||||||
|
bool ignoreSoftDeleteds = true,
|
||||||
|
Func<IQueryable<XAiProject>, IIncludableQueryable<XAiProject, object>> includeBuilder = null,
|
||||||
|
bool fillConversations = true,
|
||||||
|
CancellationToken cancellationToken = default
|
||||||
|
);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// retrieve all exists Dtos ...
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="ignoreSoftDeleteds"></param>
|
||||||
|
/// <param name="orderBuilder"></param>
|
||||||
|
/// <param name="includeBuilder"></param>
|
||||||
|
/// <param name="fillConversations"></param>
|
||||||
|
/// <param name="cancellationToken"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
Task<IEnumerable<XAiProjectDto>> GetAllAsync(
|
||||||
|
bool ignoreSoftDeleteds = true,
|
||||||
|
Func<IQueryable<XAiProject>, IOrderedQueryable<XAiProject>> orderBuilder = null,
|
||||||
|
Func<IQueryable<XAiProject>, IIncludableQueryable<XAiProject, object>> includeBuilder = null,
|
||||||
|
bool fillConversations = true,
|
||||||
|
CancellationToken cancellationToken = default
|
||||||
|
);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// retrieve all exists Dtos
|
||||||
|
/// as Async Enumerable ...
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="ignoreSoftDeleteds"></param>
|
||||||
|
/// <param name="orderBuilder"></param>
|
||||||
|
/// <param name="includeBuilder"></param>
|
||||||
|
/// <param name="fillConversations"></param>
|
||||||
|
/// <param name="cancellationToken"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
IAsyncEnumerable<XAiProjectDto> GetAllAsAsyncEnumerable(
|
||||||
|
bool ignoreSoftDeleteds = true,
|
||||||
|
Func<IQueryable<XAiProject>, IOrderedQueryable<XAiProject>> orderBuilder = null,
|
||||||
|
Func<IQueryable<XAiProject>, IIncludableQueryable<XAiProject, object>> includeBuilder = null,
|
||||||
|
bool fillConversations = true,
|
||||||
|
CancellationToken cancellationToken = default
|
||||||
|
);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// find an Dto by providing a Conditional Expression ...
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="predicate"></param>
|
||||||
|
/// <param name="ignoreSoftDeleteds"></param>
|
||||||
|
/// <param name="includeBuilder"></param>
|
||||||
|
/// <param name="fillConversations"></param>
|
||||||
|
/// <param name="cancellationToken"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
Task<XAiProjectDto> FindOneAsync(
|
||||||
|
Expression<Func<XAiProject, bool>> predicate,
|
||||||
|
bool ignoreSoftDeleteds = true,
|
||||||
|
Func<IQueryable<XAiProject>, IIncludableQueryable<XAiProject, object>> includeBuilder = null,
|
||||||
|
bool fillConversations = true,
|
||||||
|
CancellationToken cancellationToken = default
|
||||||
|
);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// find a collection of Dtos by proving a Conditional Expression ...
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="predicate"></param>
|
||||||
|
/// <param name="ignoreSoftDeleteds"></param>
|
||||||
|
/// <param name="orderBuilder"></param>
|
||||||
|
/// <param name="includeBuilder"></param>
|
||||||
|
/// <param name="fillConversations"></param>
|
||||||
|
/// <param name="cancellationToken"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
Task<IEnumerable<XAiProjectDto>> FindManyAsync(
|
||||||
|
Expression<Func<XAiProject, bool>> predicate,
|
||||||
|
bool ignoreSoftDeleteds = true,
|
||||||
|
Func<IQueryable<XAiProject>, IOrderedQueryable<XAiProject>> orderBuilder = null,
|
||||||
|
Func<IQueryable<XAiProject>, IIncludableQueryable<XAiProject, object>> includeBuilder = null,
|
||||||
|
bool fillConversations = true,
|
||||||
|
CancellationToken cancellationToken = default
|
||||||
|
);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// retrieve Dtos based on XQuery Pagination structure ...
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="query"></param>
|
||||||
|
/// <param name="ignoreSoftDeleteds"></param>
|
||||||
|
/// <param name="predicate"></param>
|
||||||
|
/// <param name="orderBuilder"></param>
|
||||||
|
/// <param name="includeBuilder"></param>
|
||||||
|
/// <param name="fillConversations"></param>
|
||||||
|
/// <param name="cancellationToken"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
Task<XQueryResult<XAiProjectDto>> QueryAsync(
|
||||||
|
XQuery query,
|
||||||
|
bool ignoreSoftDeleteds = true,
|
||||||
|
Expression<Func<XAiProject, bool>> predicate = null,
|
||||||
|
Func<IQueryable<XAiProject>, IOrderedQueryable<XAiProject>> orderBuilder = null,
|
||||||
|
Func<IQueryable<XAiProject>, IIncludableQueryable<XAiProject, object>> includeBuilder = null,
|
||||||
|
bool fillConversations = true,
|
||||||
|
CancellationToken cancellationToken = default
|
||||||
|
);
|
||||||
|
#endregion
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -1,8 +1,26 @@
|
|||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Threading;
|
||||||
|
using System.Threading.Tasks;
|
||||||
using xAiModels.Models.Dtos;
|
using xAiModels.Models.Dtos;
|
||||||
using xDataService.Interfaces;
|
using xDataService.Interfaces;
|
||||||
|
|
||||||
namespace xAiModels.Interfaces.Enrichers
|
namespace xAiModels.Interfaces.Enrichers
|
||||||
{
|
{
|
||||||
public interface IXAiProjectEnricher : IXBaseEnricher<XAiProjectDto, XAiProjectDto>
|
public interface IXAiProjectEnricher : IXBaseEnricher<XAiProjectDto, XAiProjectDto>
|
||||||
{ }
|
{
|
||||||
|
|
||||||
|
Task EnrichAsync(
|
||||||
|
XAiProjectDto source,
|
||||||
|
XAiProjectDto destination,
|
||||||
|
bool fillConversations = true,
|
||||||
|
CancellationToken cancellationToken = default
|
||||||
|
);
|
||||||
|
|
||||||
|
Task EnrichRangeAsync(
|
||||||
|
IEnumerable<XAiProjectDto> sources,
|
||||||
|
IEnumerable<XAiProjectDto> destinations,
|
||||||
|
bool fillConversations = true,
|
||||||
|
CancellationToken cancellationToken = default
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -2,6 +2,6 @@ using xStringService.Interfaces;
|
|||||||
|
|
||||||
namespace xAiModels.Interfaces
|
namespace xAiModels.Interfaces
|
||||||
{
|
{
|
||||||
public interface IXAiConversationTitleResourceProvider : IXItemResourceProvider
|
public interface IXAiConversationTitleResourceProvider : IXOwnedItemResourceProvider
|
||||||
{ }
|
{ }
|
||||||
}
|
}
|
||||||
@@ -2,6 +2,6 @@ using xStringService.Interfaces;
|
|||||||
|
|
||||||
namespace xAiModels.Interfaces
|
namespace xAiModels.Interfaces
|
||||||
{
|
{
|
||||||
public interface IXAiProjectDescriptionResourceProvider : IXItemResourceProvider
|
public interface IXAiProjectDescriptionResourceProvider : IXOwnedItemResourceProvider
|
||||||
{ }
|
{ }
|
||||||
}
|
}
|
||||||
@@ -2,6 +2,6 @@ using xStringService.Interfaces;
|
|||||||
|
|
||||||
namespace xAiModels.Interfaces
|
namespace xAiModels.Interfaces
|
||||||
{
|
{
|
||||||
public interface IXAiProjectTitleResourceProvider : IXItemResourceProvider
|
public interface IXAiProjectTitleResourceProvider : IXOwnedItemResourceProvider
|
||||||
{ }
|
{ }
|
||||||
}
|
}
|
||||||
@@ -5,8 +5,8 @@ using System.Linq.Expressions;
|
|||||||
using System.Runtime.CompilerServices;
|
using System.Runtime.CompilerServices;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using AutoMapper;
|
|
||||||
using Microsoft.EntityFrameworkCore.Query;
|
using Microsoft.EntityFrameworkCore.Query;
|
||||||
|
using xAiModels.Configurations;
|
||||||
using xAiModels.Interfaces.Dtos;
|
using xAiModels.Interfaces.Dtos;
|
||||||
using xAiModels.Interfaces.Enrichers;
|
using xAiModels.Interfaces.Enrichers;
|
||||||
using xAiModels.Interfaces.Entities;
|
using xAiModels.Interfaces.Entities;
|
||||||
@@ -24,11 +24,13 @@ namespace xAiModels.Providers.Dtos
|
|||||||
|
|
||||||
public XAiConversationRepositoryService(
|
public XAiConversationRepositoryService(
|
||||||
IXAiConversationEnricher enricher,
|
IXAiConversationEnricher enricher,
|
||||||
IXAiConversationRepository repository,
|
IXAiConversationRepository repository
|
||||||
IEnumerable<Profile> mapperProfiles = null
|
|
||||||
) : base(
|
) : base(
|
||||||
repository,
|
repository,
|
||||||
mapperProfiles
|
mapperProfiles:
|
||||||
|
[
|
||||||
|
new XAiModelMappersProfile()
|
||||||
|
]
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
this.enricher = enricher;
|
this.enricher = enricher;
|
||||||
|
|||||||
@@ -1,23 +1,487 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using AutoMapper;
|
using System.Linq;
|
||||||
|
using System.Linq.Expressions;
|
||||||
|
using System.Runtime.CompilerServices;
|
||||||
|
using System.Threading;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using Microsoft.EntityFrameworkCore.Query;
|
||||||
|
using xAiModels.Configurations;
|
||||||
using xAiModels.Interfaces.Dtos;
|
using xAiModels.Interfaces.Dtos;
|
||||||
|
using xAiModels.Interfaces.Enrichers;
|
||||||
using xAiModels.Interfaces.Entities;
|
using xAiModels.Interfaces.Entities;
|
||||||
using xAiModels.Models.Dtos;
|
using xAiModels.Models.Dtos;
|
||||||
using xAiModels.Models.Entities;
|
using xAiModels.Models.Entities;
|
||||||
|
using xCommons.Extensions;
|
||||||
using xDataService.Providers;
|
using xDataService.Providers;
|
||||||
|
using xModels.Dtos;
|
||||||
|
|
||||||
namespace xAiModels.Providers.Dtos
|
namespace xAiModels.Providers.Dtos
|
||||||
{
|
{
|
||||||
public class XAiMessageRepositoryService : XBaseRepositoryService<XAiMessage, XAiMessageDto, Guid>, IXAiMessageRepositoryService
|
public class XAiMessageRepositoryService : XBaseRepositoryService<XAiMessage, XAiMessageDto, Guid>, IXAiMessageRepositoryService
|
||||||
{
|
{
|
||||||
|
private readonly IXAiMessageEnricher enricher;
|
||||||
|
|
||||||
public XAiMessageRepositoryService(
|
public XAiMessageRepositoryService(
|
||||||
IXAiMessageRepository repository,
|
IXAiMessageEnricher enricher,
|
||||||
IEnumerable<Profile> mapperProfiles = null
|
IXAiMessageRepository repository
|
||||||
) : base(
|
) : base(
|
||||||
repository,
|
repository,
|
||||||
mapperProfiles
|
mapperProfiles:
|
||||||
|
[
|
||||||
|
new XAiModelMappersProfile()
|
||||||
|
]
|
||||||
)
|
)
|
||||||
{ }
|
{
|
||||||
|
this.enricher = enricher;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
#region Actions ...
|
||||||
|
//
|
||||||
|
#region Add ...
|
||||||
|
/// <summary>
|
||||||
|
/// add a new Dto ...
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="item"></param>
|
||||||
|
/// <param name="saveChanges"></param>
|
||||||
|
/// <param name="cancellationToken"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public override async Task<XAiMessageDto> AddAsync(
|
||||||
|
XAiMessageDto item,
|
||||||
|
bool saveChanges = true,
|
||||||
|
CancellationToken cancellationToken = default
|
||||||
|
)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
var result = await base.AddAsync(
|
||||||
|
item: item,
|
||||||
|
saveChanges: saveChanges,
|
||||||
|
cancellationToken: cancellationToken
|
||||||
|
);
|
||||||
|
|
||||||
|
//
|
||||||
|
// Do Enrichment if result Exists ...
|
||||||
|
if (!result.IsNullOrDefault())
|
||||||
|
{
|
||||||
|
//
|
||||||
|
await enricher.EnrichAsync(
|
||||||
|
source: result,
|
||||||
|
destination: result,
|
||||||
|
cancellationToken: cancellationToken
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// add or update a Dto (add if not exists/update if exists) ...
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="item"></param>
|
||||||
|
/// <param name="saveChanges"></param>
|
||||||
|
/// <param name="cancellationToken"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public override async Task<XAiMessageDto> AddOrUpdateAsync(
|
||||||
|
XAiMessageDto item,
|
||||||
|
bool saveChanges = true,
|
||||||
|
CancellationToken cancellationToken = default
|
||||||
|
)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
var result = await base.AddAsync(
|
||||||
|
item: item,
|
||||||
|
saveChanges: saveChanges,
|
||||||
|
cancellationToken: cancellationToken
|
||||||
|
);
|
||||||
|
|
||||||
|
//
|
||||||
|
// Do Enrichment if result Exists ...
|
||||||
|
if (!result.IsNullOrDefault())
|
||||||
|
{
|
||||||
|
//
|
||||||
|
await enricher.EnrichAsync(
|
||||||
|
source: result,
|
||||||
|
destination: result,
|
||||||
|
cancellationToken: cancellationToken
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
//
|
||||||
|
#region Update ...
|
||||||
|
/// <summary>
|
||||||
|
/// Update an Dto values ...
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="id"></param>
|
||||||
|
/// <param name="item"></param>
|
||||||
|
/// <param name="saveChanges"></param>
|
||||||
|
/// <param name="cancellationToken"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public override async Task<XAiMessageDto> UpdateAsync(
|
||||||
|
Guid id,
|
||||||
|
XAiMessageDto item,
|
||||||
|
bool saveChanges = true,
|
||||||
|
CancellationToken cancellationToken = default
|
||||||
|
)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
var result = await base.UpdateAsync(
|
||||||
|
id: id,
|
||||||
|
item: item,
|
||||||
|
saveChanges: saveChanges,
|
||||||
|
cancellationToken: cancellationToken
|
||||||
|
);
|
||||||
|
|
||||||
|
//
|
||||||
|
// Do Enrichment if result Exists ...
|
||||||
|
if (!result.IsNullOrDefault())
|
||||||
|
{
|
||||||
|
//
|
||||||
|
await enricher.EnrichAsync(
|
||||||
|
source: result,
|
||||||
|
destination: result,
|
||||||
|
cancellationToken: cancellationToken
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
//
|
||||||
|
#region Remove ...
|
||||||
|
/// <summary>
|
||||||
|
/// remove an Dto by it's Id ...
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="id"></param>
|
||||||
|
/// <param name="softDelete"></param>
|
||||||
|
/// <param name="saveChanges"></param>
|
||||||
|
/// <param name="cancellationToken"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public override async Task<XAiMessageDto> RemoveAsync(
|
||||||
|
Guid id,
|
||||||
|
bool softDelete = true,
|
||||||
|
bool saveChanges = true,
|
||||||
|
CancellationToken cancellationToken = default
|
||||||
|
)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
var result = await base.RemoveAsync(
|
||||||
|
id: id,
|
||||||
|
softDelete: softDelete,
|
||||||
|
saveChanges: saveChanges,
|
||||||
|
cancellationToken: cancellationToken
|
||||||
|
);
|
||||||
|
|
||||||
|
//
|
||||||
|
// Do Enrichment if result Exists ...
|
||||||
|
if (!result.IsNullOrDefault())
|
||||||
|
{
|
||||||
|
//
|
||||||
|
await enricher.EnrichAsync(
|
||||||
|
source: result,
|
||||||
|
destination: result,
|
||||||
|
cancellationToken: cancellationToken
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// remove an Dto ...
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="item"></param>
|
||||||
|
/// <param name="softDelete"></param>
|
||||||
|
/// <param name="saveChanges"></param>
|
||||||
|
/// <param name="cancellationToken"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public override async Task<XAiMessageDto> RemoveAsync(
|
||||||
|
XAiMessageDto item,
|
||||||
|
bool softDelete = true,
|
||||||
|
bool saveChanges = true,
|
||||||
|
CancellationToken cancellationToken = default
|
||||||
|
)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
var result = await base.RemoveAsync(
|
||||||
|
item: item,
|
||||||
|
softDelete: softDelete,
|
||||||
|
saveChanges: saveChanges,
|
||||||
|
cancellationToken: cancellationToken
|
||||||
|
);
|
||||||
|
|
||||||
|
//
|
||||||
|
// Do Enrichment if result Exists ...
|
||||||
|
if (!result.IsNullOrDefault())
|
||||||
|
{
|
||||||
|
//
|
||||||
|
await enricher.EnrichAsync(
|
||||||
|
source: result,
|
||||||
|
destination: result,
|
||||||
|
cancellationToken: cancellationToken
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
//
|
||||||
|
#region Retrieve ...
|
||||||
|
/// <summary>
|
||||||
|
/// retrieve an Dto by it's Id ...
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="id"></param>
|
||||||
|
/// <param name="ignoreSoftDeleteds"></param>
|
||||||
|
/// <param name="includeBuilder"></param>
|
||||||
|
/// <param name="cancellationToken"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public override async Task<XAiMessageDto> GetAsync(
|
||||||
|
Guid id,
|
||||||
|
bool ignoreSoftDeleteds = true,
|
||||||
|
Func<IQueryable<XAiMessage>, IIncludableQueryable<XAiMessage, object>> includeBuilder = null,
|
||||||
|
CancellationToken cancellationToken = default
|
||||||
|
)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
var result = await base.GetAsync(
|
||||||
|
id: id,
|
||||||
|
includeBuilder: includeBuilder,
|
||||||
|
cancellationToken: cancellationToken,
|
||||||
|
ignoreSoftDeleteds: ignoreSoftDeleteds
|
||||||
|
);
|
||||||
|
|
||||||
|
//
|
||||||
|
// Do Enrichment if result Exists ...
|
||||||
|
if (!result.IsNullOrDefault())
|
||||||
|
{
|
||||||
|
//
|
||||||
|
await enricher.EnrichAsync(
|
||||||
|
source: result,
|
||||||
|
destination: result,
|
||||||
|
cancellationToken: cancellationToken
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// retrieve all exists Dtos ...
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="ignoreSoftDeleteds"></param>
|
||||||
|
/// <param name="orderBuilder"></param>
|
||||||
|
/// <param name="includeBuilder"></param>
|
||||||
|
/// <param name="cancellationToken"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public override async Task<IEnumerable<XAiMessageDto>> GetAllAsync(
|
||||||
|
bool ignoreSoftDeleteds = true,
|
||||||
|
Func<IQueryable<XAiMessage>, IOrderedQueryable<XAiMessage>> orderBuilder = null,
|
||||||
|
Func<IQueryable<XAiMessage>, IIncludableQueryable<XAiMessage, object>> includeBuilder = null,
|
||||||
|
CancellationToken cancellationToken = default
|
||||||
|
)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
var result = await base.GetAllAsync(
|
||||||
|
orderBuilder: orderBuilder,
|
||||||
|
includeBuilder: includeBuilder,
|
||||||
|
cancellationToken: cancellationToken,
|
||||||
|
ignoreSoftDeleteds: ignoreSoftDeleteds
|
||||||
|
);
|
||||||
|
|
||||||
|
//
|
||||||
|
// Do Enrichment if result Exists ...
|
||||||
|
if (!result.IsNullOrDefault())
|
||||||
|
{
|
||||||
|
//
|
||||||
|
await enricher.EnrichRangeAsync(
|
||||||
|
sources: result,
|
||||||
|
destinations: result,
|
||||||
|
cancellationToken: cancellationToken
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// retrieve all exists Dtos
|
||||||
|
/// as Async Enumerable ...
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="ignoreSoftDeleteds"></param>
|
||||||
|
/// <param name="orderBuilder"></param>
|
||||||
|
/// <param name="includeBuilder"></param>
|
||||||
|
/// <param name="cancellationToken"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public override async IAsyncEnumerable<XAiMessageDto> GetAllAsAsyncEnumerable(
|
||||||
|
bool ignoreSoftDeleteds = true,
|
||||||
|
Func<IQueryable<XAiMessage>, IOrderedQueryable<XAiMessage>> orderBuilder = null,
|
||||||
|
Func<IQueryable<XAiMessage>, IIncludableQueryable<XAiMessage, object>> includeBuilder = null,
|
||||||
|
[EnumeratorCancellation] CancellationToken cancellationToken = default
|
||||||
|
)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
var enumerable = base.GetAllAsAsyncEnumerable(
|
||||||
|
orderBuilder: orderBuilder,
|
||||||
|
includeBuilder: includeBuilder,
|
||||||
|
ignoreSoftDeleteds: ignoreSoftDeleteds
|
||||||
|
);
|
||||||
|
await foreach (var dto in enumerable)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
if (cancellationToken.IsCancellationRequested)
|
||||||
|
{
|
||||||
|
yield break;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
await enricher.EnrichAsync(
|
||||||
|
source: dto,
|
||||||
|
destination: dto,
|
||||||
|
cancellationToken: cancellationToken
|
||||||
|
);
|
||||||
|
yield return dto;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// find an Dto by providing a Conditional Expression ...
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="predicate"></param>
|
||||||
|
/// <param name="ignoreSoftDeleteds"></param>
|
||||||
|
/// <param name="includeBuilder"></param>
|
||||||
|
/// <param name="cancellationToken"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public override async Task<XAiMessageDto> FindOneAsync(
|
||||||
|
Expression<Func<XAiMessage, bool>> predicate,
|
||||||
|
bool ignoreSoftDeleteds = true,
|
||||||
|
Func<IQueryable<XAiMessage>, IIncludableQueryable<XAiMessage, object>> includeBuilder = null,
|
||||||
|
CancellationToken cancellationToken = default
|
||||||
|
)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
var result = await base.FindOneAsync(
|
||||||
|
predicate: predicate,
|
||||||
|
includeBuilder: includeBuilder,
|
||||||
|
cancellationToken: cancellationToken,
|
||||||
|
ignoreSoftDeleteds: ignoreSoftDeleteds
|
||||||
|
);
|
||||||
|
|
||||||
|
//
|
||||||
|
// Do Enrichment if result Exists ...
|
||||||
|
if (!result.IsNullOrDefault())
|
||||||
|
{
|
||||||
|
//
|
||||||
|
await enricher.EnrichAsync(
|
||||||
|
source: result,
|
||||||
|
destination: result,
|
||||||
|
cancellationToken: cancellationToken
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// find a collection of Dtos by proving a Conditional Expression ...
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="predicate"></param>
|
||||||
|
/// <param name="ignoreSoftDeleteds"></param>
|
||||||
|
/// <param name="orderBuilder"></param>
|
||||||
|
/// <param name="includeBuilder"></param>
|
||||||
|
/// <param name="cancellationToken"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public override async Task<IEnumerable<XAiMessageDto>> FindManyAsync(
|
||||||
|
Expression<Func<XAiMessage, bool>> predicate,
|
||||||
|
bool ignoreSoftDeleteds = true,
|
||||||
|
Func<IQueryable<XAiMessage>, IOrderedQueryable<XAiMessage>> orderBuilder = null,
|
||||||
|
Func<IQueryable<XAiMessage>, IIncludableQueryable<XAiMessage, object>> includeBuilder = null,
|
||||||
|
CancellationToken cancellationToken = default
|
||||||
|
)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
var result = await base.FindManyAsync(
|
||||||
|
predicate: predicate,
|
||||||
|
orderBuilder: orderBuilder,
|
||||||
|
includeBuilder: includeBuilder,
|
||||||
|
cancellationToken: cancellationToken,
|
||||||
|
ignoreSoftDeleteds: ignoreSoftDeleteds
|
||||||
|
);
|
||||||
|
|
||||||
|
//
|
||||||
|
// Do Enrichment if result Exists ...
|
||||||
|
if (!result.IsNullOrDefault())
|
||||||
|
{
|
||||||
|
//
|
||||||
|
await enricher.EnrichRangeAsync(
|
||||||
|
sources: result,
|
||||||
|
destinations: result,
|
||||||
|
cancellationToken: cancellationToken
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// retrieve Dtos based on XQuery Pagination structure ...
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="query"></param>
|
||||||
|
/// <param name="ignoreSoftDeleteds"></param>
|
||||||
|
/// <param name="predicate"></param>
|
||||||
|
/// <param name="orderBuilder"></param>
|
||||||
|
/// <param name="includeBuilder"></param>
|
||||||
|
/// <param name="cancellationToken"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public override async Task<XQueryResult<XAiMessageDto>> QueryAsync(
|
||||||
|
XQuery query,
|
||||||
|
bool ignoreSoftDeleteds = true,
|
||||||
|
Expression<Func<XAiMessage, bool>> predicate = null,
|
||||||
|
Func<IQueryable<XAiMessage>, IOrderedQueryable<XAiMessage>> orderBuilder = null,
|
||||||
|
Func<IQueryable<XAiMessage>, IIncludableQueryable<XAiMessage, object>> includeBuilder = null,
|
||||||
|
CancellationToken cancellationToken = default
|
||||||
|
)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
var result = await base.QueryAsync(
|
||||||
|
query: query,
|
||||||
|
predicate: predicate,
|
||||||
|
orderBuilder: orderBuilder,
|
||||||
|
includeBuilder: includeBuilder,
|
||||||
|
cancellationToken: cancellationToken,
|
||||||
|
ignoreSoftDeleteds: ignoreSoftDeleteds
|
||||||
|
);
|
||||||
|
|
||||||
|
//
|
||||||
|
// Do Enrichment if result Exists ...
|
||||||
|
if (!result.IsNullOrDefault())
|
||||||
|
{
|
||||||
|
//
|
||||||
|
await enricher.EnrichRangeAsync(
|
||||||
|
sources: result.Items,
|
||||||
|
destinations: result.Items,
|
||||||
|
cancellationToken: cancellationToken
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
#endregion
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,23 +1,803 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using AutoMapper;
|
using System.Linq;
|
||||||
|
using System.Linq.Expressions;
|
||||||
|
using System.Runtime.CompilerServices;
|
||||||
|
using System.Threading;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using Microsoft.EntityFrameworkCore.Query;
|
||||||
|
using xAiModels.Configurations;
|
||||||
using xAiModels.Interfaces.Dtos;
|
using xAiModels.Interfaces.Dtos;
|
||||||
|
using xAiModels.Interfaces.Enrichers;
|
||||||
using xAiModels.Interfaces.Entities;
|
using xAiModels.Interfaces.Entities;
|
||||||
using xAiModels.Models.Dtos;
|
using xAiModels.Models.Dtos;
|
||||||
using xAiModels.Models.Entities;
|
using xAiModels.Models.Entities;
|
||||||
|
using xCommons.Extensions;
|
||||||
using xDataService.Providers;
|
using xDataService.Providers;
|
||||||
|
using xModels.Dtos;
|
||||||
|
|
||||||
namespace xAiModels.Providers.Dtos
|
namespace xAiModels.Providers.Dtos
|
||||||
{
|
{
|
||||||
public class XAiProjectRepositoryService : XBaseRepositoryService<XAiProject, XAiProjectDto, Guid>, IXAiProjectRepositoryService
|
public class XAiProjectRepositoryService : XBaseRepositoryService<XAiProject, XAiProjectDto, Guid>, IXAiProjectRepositoryService
|
||||||
{
|
{
|
||||||
|
private readonly IXAiProjectEnricher enricher;
|
||||||
|
|
||||||
public XAiProjectRepositoryService(
|
public XAiProjectRepositoryService(
|
||||||
IXAiProjectRepository repository,
|
IXAiProjectEnricher enricher,
|
||||||
IEnumerable<Profile> mapperProfiles = null
|
IXAiProjectRepository repository
|
||||||
) : base(
|
) : base(
|
||||||
repository,
|
repository,
|
||||||
mapperProfiles
|
mapperProfiles:
|
||||||
|
[
|
||||||
|
new XAiModelMappersProfile()
|
||||||
|
]
|
||||||
)
|
)
|
||||||
{ }
|
{
|
||||||
|
this.enricher = enricher;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//
|
||||||
|
#region Actions Base ...
|
||||||
|
//
|
||||||
|
#region Add ...
|
||||||
|
/// <summary>
|
||||||
|
/// add a new Dto ...
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="item"></param>
|
||||||
|
/// <param name="saveChanges"></param>
|
||||||
|
/// <param name="cancellationToken"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public override async Task<XAiProjectDto> AddAsync(
|
||||||
|
XAiProjectDto item,
|
||||||
|
bool saveChanges = true,
|
||||||
|
CancellationToken cancellationToken = default
|
||||||
|
)
|
||||||
|
{
|
||||||
|
return await AddAsync(
|
||||||
|
item: item,
|
||||||
|
saveChanges: saveChanges,
|
||||||
|
fillConversations: false,
|
||||||
|
cancellationToken: cancellationToken
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// add or update a Dto (add if not exists/update if exists) ...
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="item"></param>
|
||||||
|
/// <param name="saveChanges"></param>
|
||||||
|
/// <param name="cancellationToken"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public override async Task<XAiProjectDto> AddOrUpdateAsync(
|
||||||
|
XAiProjectDto item,
|
||||||
|
bool saveChanges = true,
|
||||||
|
CancellationToken cancellationToken = default
|
||||||
|
)
|
||||||
|
{
|
||||||
|
return await AddOrUpdateAsync(
|
||||||
|
item: item,
|
||||||
|
saveChanges: saveChanges,
|
||||||
|
fillConversations: false,
|
||||||
|
cancellationToken: cancellationToken
|
||||||
|
);
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
//
|
||||||
|
#region Update ...
|
||||||
|
/// <summary>
|
||||||
|
/// Update an Dto values ...
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="id"></param>
|
||||||
|
/// <param name="item"></param>
|
||||||
|
/// <param name="saveChanges"></param>
|
||||||
|
/// <param name="cancellationToken"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public override async Task<XAiProjectDto> UpdateAsync(
|
||||||
|
Guid id,
|
||||||
|
XAiProjectDto item,
|
||||||
|
bool saveChanges = true,
|
||||||
|
CancellationToken cancellationToken = default
|
||||||
|
)
|
||||||
|
{
|
||||||
|
return await UpdateAsync(
|
||||||
|
id: id,
|
||||||
|
item: item,
|
||||||
|
saveChanges: saveChanges,
|
||||||
|
fillConversations: false,
|
||||||
|
cancellationToken: cancellationToken
|
||||||
|
);
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
//
|
||||||
|
#region Remove ...
|
||||||
|
/// <summary>
|
||||||
|
/// remove an Dto by it's Id ...
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="id"></param>
|
||||||
|
/// <param name="softDelete"></param>
|
||||||
|
/// <param name="saveChanges"></param>
|
||||||
|
/// <param name="cancellationToken"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public override async Task<XAiProjectDto> RemoveAsync(
|
||||||
|
Guid id,
|
||||||
|
bool softDelete = false,
|
||||||
|
bool saveChanges = true,
|
||||||
|
CancellationToken cancellationToken = default
|
||||||
|
)
|
||||||
|
{
|
||||||
|
return await RemoveAsync(
|
||||||
|
id: id,
|
||||||
|
softDelete: softDelete,
|
||||||
|
saveChanges: saveChanges,
|
||||||
|
fillConversations: false,
|
||||||
|
cancellationToken: cancellationToken
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// remove an Dto ...
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="item"></param>
|
||||||
|
/// <param name="softDelete"></param>
|
||||||
|
/// <param name="saveChanges"></param>
|
||||||
|
/// <param name="cancellationToken"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public override async Task<XAiProjectDto> RemoveAsync(
|
||||||
|
XAiProjectDto item,
|
||||||
|
bool softDelete = false,
|
||||||
|
bool saveChanges = true,
|
||||||
|
CancellationToken cancellationToken = default
|
||||||
|
)
|
||||||
|
{
|
||||||
|
return await RemoveAsync(
|
||||||
|
item: item,
|
||||||
|
softDelete: softDelete,
|
||||||
|
saveChanges: saveChanges,
|
||||||
|
fillConversations: false,
|
||||||
|
cancellationToken: cancellationToken
|
||||||
|
);
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
//
|
||||||
|
#region Retrieve ...
|
||||||
|
/// <summary>
|
||||||
|
/// retrieve an Dto by it's Id ...
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="id"></param>
|
||||||
|
/// <param name="ignoreSoftDeleteds"></param>
|
||||||
|
/// <param name="includeBuilder"></param>
|
||||||
|
/// <param name="cancellationToken"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public override async Task<XAiProjectDto> GetAsync(
|
||||||
|
Guid id,
|
||||||
|
bool ignoreSoftDeleteds = true,
|
||||||
|
Func<IQueryable<XAiProject>, IIncludableQueryable<XAiProject, object>> includeBuilder = null,
|
||||||
|
CancellationToken cancellationToken = default
|
||||||
|
)
|
||||||
|
{
|
||||||
|
return await GetAsync(
|
||||||
|
id: id,
|
||||||
|
fillConversations: false,
|
||||||
|
includeBuilder: includeBuilder,
|
||||||
|
cancellationToken: cancellationToken,
|
||||||
|
ignoreSoftDeleteds: ignoreSoftDeleteds
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// retrieve all exists Dtos ...
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="ignoreSoftDeleteds"></param>
|
||||||
|
/// <param name="orderBuilder"></param>
|
||||||
|
/// <param name="includeBuilder"></param>
|
||||||
|
/// <param name="cancellationToken"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public override async Task<IEnumerable<XAiProjectDto>> GetAllAsync(
|
||||||
|
bool ignoreSoftDeleteds = true,
|
||||||
|
Func<IQueryable<XAiProject>, IOrderedQueryable<XAiProject>> orderBuilder = null,
|
||||||
|
Func<IQueryable<XAiProject>, IIncludableQueryable<XAiProject, object>> includeBuilder = null,
|
||||||
|
CancellationToken cancellationToken = default
|
||||||
|
)
|
||||||
|
{
|
||||||
|
return await GetAllAsync(
|
||||||
|
fillConversations: false,
|
||||||
|
orderBuilder: orderBuilder,
|
||||||
|
includeBuilder: includeBuilder,
|
||||||
|
cancellationToken: cancellationToken,
|
||||||
|
ignoreSoftDeleteds: ignoreSoftDeleteds
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// retrieve all exists Dtos
|
||||||
|
/// as Async Enumerable ...
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="ignoreSoftDeleteds"></param>
|
||||||
|
/// <param name="orderBuilder"></param>
|
||||||
|
/// <param name="includeBuilder"></param>
|
||||||
|
/// <param name="cancellationToken"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public override IAsyncEnumerable<XAiProjectDto> GetAllAsAsyncEnumerable(
|
||||||
|
bool ignoreSoftDeleteds = true,
|
||||||
|
Func<IQueryable<XAiProject>, IOrderedQueryable<XAiProject>> orderBuilder = null,
|
||||||
|
Func<IQueryable<XAiProject>, IIncludableQueryable<XAiProject, object>> includeBuilder = null,
|
||||||
|
CancellationToken cancellationToken = default
|
||||||
|
)
|
||||||
|
{
|
||||||
|
return GetAllAsAsyncEnumerable(
|
||||||
|
fillConversations: false,
|
||||||
|
orderBuilder: orderBuilder,
|
||||||
|
includeBuilder: includeBuilder,
|
||||||
|
cancellationToken: cancellationToken,
|
||||||
|
ignoreSoftDeleteds: ignoreSoftDeleteds
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// find an Dto by providing a Conditional Expression ...
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="predicate"></param>
|
||||||
|
/// <param name="ignoreSoftDeleteds"></param>
|
||||||
|
/// <param name="includeBuilder"></param>
|
||||||
|
/// <param name="cancellationToken"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public override async Task<XAiProjectDto> FindOneAsync(
|
||||||
|
Expression<Func<XAiProject, bool>> predicate,
|
||||||
|
bool ignoreSoftDeleteds = true,
|
||||||
|
Func<IQueryable<XAiProject>, IIncludableQueryable<XAiProject, object>> includeBuilder = null,
|
||||||
|
CancellationToken cancellationToken = default
|
||||||
|
)
|
||||||
|
{
|
||||||
|
return await FindOneAsync(
|
||||||
|
predicate: predicate,
|
||||||
|
fillConversations: false,
|
||||||
|
includeBuilder: includeBuilder,
|
||||||
|
cancellationToken: cancellationToken,
|
||||||
|
ignoreSoftDeleteds: ignoreSoftDeleteds
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// find a collection of Dtos by proving a Conditional Expression ...
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="predicate"></param>
|
||||||
|
/// <param name="ignoreSoftDeleteds"></param>
|
||||||
|
/// <param name="orderBuilder"></param>
|
||||||
|
/// <param name="includeBuilder"></param>
|
||||||
|
/// <param name="cancellationToken"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public override async Task<IEnumerable<XAiProjectDto>> FindManyAsync(
|
||||||
|
Expression<Func<XAiProject, bool>> predicate,
|
||||||
|
bool ignoreSoftDeleteds = true,
|
||||||
|
Func<IQueryable<XAiProject>, IOrderedQueryable<XAiProject>> orderBuilder = null,
|
||||||
|
Func<IQueryable<XAiProject>, IIncludableQueryable<XAiProject, object>> includeBuilder = null,
|
||||||
|
CancellationToken cancellationToken = default
|
||||||
|
)
|
||||||
|
{
|
||||||
|
return await FindManyAsync(
|
||||||
|
predicate: predicate,
|
||||||
|
fillConversations: false,
|
||||||
|
orderBuilder: orderBuilder,
|
||||||
|
includeBuilder: includeBuilder,
|
||||||
|
cancellationToken: cancellationToken,
|
||||||
|
ignoreSoftDeleteds: ignoreSoftDeleteds
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// retrieve Dtos based on XQuery Pagination structure ...
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="query"></param>
|
||||||
|
/// <param name="ignoreSoftDeleteds"></param>
|
||||||
|
/// <param name="predicate"></param>
|
||||||
|
/// <param name="orderBuilder"></param>
|
||||||
|
/// <param name="includeBuilder"></param>
|
||||||
|
/// <param name="cancellationToken"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public override async Task<XQueryResult<XAiProjectDto>> QueryAsync(
|
||||||
|
XQuery query,
|
||||||
|
bool ignoreSoftDeleteds = true,
|
||||||
|
Expression<Func<XAiProject, bool>> predicate = null,
|
||||||
|
Func<IQueryable<XAiProject>, IOrderedQueryable<XAiProject>> orderBuilder = null,
|
||||||
|
Func<IQueryable<XAiProject>, IIncludableQueryable<XAiProject, object>> includeBuilder = null,
|
||||||
|
CancellationToken cancellationToken = default
|
||||||
|
)
|
||||||
|
{
|
||||||
|
return await QueryAsync(
|
||||||
|
query: query,
|
||||||
|
predicate: predicate,
|
||||||
|
orderBuilder: orderBuilder,
|
||||||
|
includeBuilder: includeBuilder,
|
||||||
|
cancellationToken: cancellationToken,
|
||||||
|
ignoreSoftDeleteds: ignoreSoftDeleteds
|
||||||
|
);
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
//
|
||||||
|
#region Actions ...
|
||||||
|
//
|
||||||
|
#region Add ...
|
||||||
|
/// <summary>
|
||||||
|
/// add a new Dto ...
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="item"></param>
|
||||||
|
/// <param name="saveChanges"></param>
|
||||||
|
/// <param name="fillConversations"></param>
|
||||||
|
/// <param name="cancellationToken"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public virtual async Task<XAiProjectDto> AddAsync(
|
||||||
|
XAiProjectDto item,
|
||||||
|
bool saveChanges = true,
|
||||||
|
bool fillConversations = true,
|
||||||
|
CancellationToken cancellationToken = default
|
||||||
|
)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
var result = await base.AddAsync(
|
||||||
|
item: item,
|
||||||
|
saveChanges: saveChanges,
|
||||||
|
cancellationToken: cancellationToken
|
||||||
|
);
|
||||||
|
|
||||||
|
//
|
||||||
|
// Do Enrichment if result Exists ...
|
||||||
|
if (!result.IsNullOrDefault())
|
||||||
|
{
|
||||||
|
//
|
||||||
|
await enricher.EnrichAsync(
|
||||||
|
source: result,
|
||||||
|
destination: result,
|
||||||
|
fillConversations: fillConversations,
|
||||||
|
cancellationToken: cancellationToken
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// add or update a Dto (add if not exists/update if exists) ...
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="item"></param>
|
||||||
|
/// <param name="saveChanges"></param>
|
||||||
|
/// <param name="fillConversations"></param>
|
||||||
|
/// <param name="cancellationToken"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public virtual async Task<XAiProjectDto> AddOrUpdateAsync(
|
||||||
|
XAiProjectDto item,
|
||||||
|
bool saveChanges = true,
|
||||||
|
bool fillConversations = true,
|
||||||
|
CancellationToken cancellationToken = default
|
||||||
|
)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
var result = await base.AddAsync(
|
||||||
|
item: item,
|
||||||
|
saveChanges: saveChanges,
|
||||||
|
cancellationToken: cancellationToken
|
||||||
|
);
|
||||||
|
|
||||||
|
//
|
||||||
|
// Do Enrichment if result Exists ...
|
||||||
|
if (!result.IsNullOrDefault())
|
||||||
|
{
|
||||||
|
//
|
||||||
|
await enricher.EnrichAsync(
|
||||||
|
source: result,
|
||||||
|
destination: result,
|
||||||
|
fillConversations: fillConversations,
|
||||||
|
cancellationToken: cancellationToken
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
//
|
||||||
|
#region Update ...
|
||||||
|
/// <summary>
|
||||||
|
/// Update an Dto values ...
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="id"></param>
|
||||||
|
/// <param name="item"></param>
|
||||||
|
/// <param name="saveChanges"></param>
|
||||||
|
/// <param name="fillConversations"></param>
|
||||||
|
/// <param name="cancellationToken"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public virtual async Task<XAiProjectDto> UpdateAsync(
|
||||||
|
Guid id,
|
||||||
|
XAiProjectDto item,
|
||||||
|
bool saveChanges = true,
|
||||||
|
bool fillConversations = true,
|
||||||
|
CancellationToken cancellationToken = default
|
||||||
|
)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
var result = await base.UpdateAsync(
|
||||||
|
id: id,
|
||||||
|
item: item,
|
||||||
|
saveChanges: saveChanges,
|
||||||
|
cancellationToken: cancellationToken
|
||||||
|
);
|
||||||
|
|
||||||
|
//
|
||||||
|
// Do Enrichment if result Exists ...
|
||||||
|
if (!result.IsNullOrDefault())
|
||||||
|
{
|
||||||
|
//
|
||||||
|
await enricher.EnrichAsync(
|
||||||
|
source: result,
|
||||||
|
destination: result,
|
||||||
|
fillConversations: fillConversations,
|
||||||
|
cancellationToken: cancellationToken
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
//
|
||||||
|
#region Remove ...
|
||||||
|
/// <summary>
|
||||||
|
/// remove an Dto by it's Id ...
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="id"></param>
|
||||||
|
/// <param name="softDelete"></param>
|
||||||
|
/// <param name="saveChanges"></param>
|
||||||
|
/// <param name="fillConversations"></param>
|
||||||
|
/// <param name="cancellationToken"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public virtual async Task<XAiProjectDto> RemoveAsync(
|
||||||
|
Guid id,
|
||||||
|
bool softDelete = false,
|
||||||
|
bool saveChanges = true,
|
||||||
|
bool fillConversations = true,
|
||||||
|
CancellationToken cancellationToken = default
|
||||||
|
)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
var result = await base.RemoveAsync(
|
||||||
|
id: id,
|
||||||
|
softDelete: softDelete,
|
||||||
|
saveChanges: saveChanges,
|
||||||
|
cancellationToken: cancellationToken
|
||||||
|
);
|
||||||
|
|
||||||
|
//
|
||||||
|
// Do Enrichment if result Exists ...
|
||||||
|
if (!result.IsNullOrDefault())
|
||||||
|
{
|
||||||
|
//
|
||||||
|
await enricher.EnrichAsync(
|
||||||
|
source: result,
|
||||||
|
destination: result,
|
||||||
|
fillConversations: fillConversations,
|
||||||
|
cancellationToken: cancellationToken
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// remove an Dto ...
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="item"></param>
|
||||||
|
/// <param name="softDelete"></param>
|
||||||
|
/// <param name="saveChanges"></param>
|
||||||
|
/// <param name="fillConversations"></param>
|
||||||
|
/// <param name="cancellationToken"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public virtual async Task<XAiProjectDto> RemoveAsync(
|
||||||
|
XAiProjectDto item,
|
||||||
|
bool softDelete = false,
|
||||||
|
bool saveChanges = true,
|
||||||
|
bool fillConversations = true,
|
||||||
|
CancellationToken cancellationToken = default
|
||||||
|
)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
var result = await base.RemoveAsync(
|
||||||
|
item: item,
|
||||||
|
softDelete: softDelete,
|
||||||
|
saveChanges: saveChanges,
|
||||||
|
cancellationToken: cancellationToken
|
||||||
|
);
|
||||||
|
|
||||||
|
//
|
||||||
|
// Do Enrichment if result Exists ...
|
||||||
|
if (!result.IsNullOrDefault())
|
||||||
|
{
|
||||||
|
//
|
||||||
|
await enricher.EnrichAsync(
|
||||||
|
source: result,
|
||||||
|
destination: result,
|
||||||
|
fillConversations: fillConversations,
|
||||||
|
cancellationToken: cancellationToken
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
//
|
||||||
|
#region Retrieve ...
|
||||||
|
/// <summary>
|
||||||
|
/// retrieve an Dto by it's Id ...
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="id"></param>
|
||||||
|
/// <param name="ignoreSoftDeleteds"></param>
|
||||||
|
/// <param name="includeBuilder"></param>
|
||||||
|
/// <param name="fillConversations"></param>
|
||||||
|
/// <param name="cancellationToken"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public virtual async Task<XAiProjectDto> GetAsync(
|
||||||
|
Guid id,
|
||||||
|
bool ignoreSoftDeleteds = true,
|
||||||
|
Func<IQueryable<XAiProject>, IIncludableQueryable<XAiProject, object>> includeBuilder = null,
|
||||||
|
bool fillConversations = true,
|
||||||
|
CancellationToken cancellationToken = default
|
||||||
|
)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
var result = await base.GetAsync(
|
||||||
|
id: id,
|
||||||
|
includeBuilder: includeBuilder,
|
||||||
|
cancellationToken: cancellationToken,
|
||||||
|
ignoreSoftDeleteds: ignoreSoftDeleteds
|
||||||
|
);
|
||||||
|
|
||||||
|
//
|
||||||
|
// Do Enrichment if result Exists ...
|
||||||
|
if (!result.IsNullOrDefault())
|
||||||
|
{
|
||||||
|
//
|
||||||
|
await enricher.EnrichAsync(
|
||||||
|
source: result,
|
||||||
|
destination: result,
|
||||||
|
fillConversations: fillConversations,
|
||||||
|
cancellationToken: cancellationToken
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// retrieve all exists Dtos ...
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="ignoreSoftDeleteds"></param>
|
||||||
|
/// <param name="orderBuilder"></param>
|
||||||
|
/// <param name="includeBuilder"></param>
|
||||||
|
/// <param name="fillConversations"></param>
|
||||||
|
/// <param name="cancellationToken"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public virtual async Task<IEnumerable<XAiProjectDto>> GetAllAsync(
|
||||||
|
bool ignoreSoftDeleteds = true,
|
||||||
|
Func<IQueryable<XAiProject>, IOrderedQueryable<XAiProject>> orderBuilder = null,
|
||||||
|
Func<IQueryable<XAiProject>, IIncludableQueryable<XAiProject, object>> includeBuilder = null,
|
||||||
|
bool fillConversations = true,
|
||||||
|
CancellationToken cancellationToken = default
|
||||||
|
)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
var result = await base.GetAllAsync(
|
||||||
|
orderBuilder: orderBuilder,
|
||||||
|
includeBuilder: includeBuilder,
|
||||||
|
cancellationToken: cancellationToken,
|
||||||
|
ignoreSoftDeleteds: ignoreSoftDeleteds
|
||||||
|
);
|
||||||
|
|
||||||
|
//
|
||||||
|
// Do Enrichment if result Exists ...
|
||||||
|
if (!result.IsNullOrDefault())
|
||||||
|
{
|
||||||
|
//
|
||||||
|
await enricher.EnrichRangeAsync(
|
||||||
|
sources: result,
|
||||||
|
destinations: result,
|
||||||
|
fillConversations: fillConversations,
|
||||||
|
cancellationToken: cancellationToken
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// retrieve all exists Dtos
|
||||||
|
/// as Async Enumerable ...
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="ignoreSoftDeleteds"></param>
|
||||||
|
/// <param name="orderBuilder"></param>
|
||||||
|
/// <param name="includeBuilder"></param>
|
||||||
|
/// <param name="fillConversations"></param>
|
||||||
|
/// <param name="cancellationToken"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public virtual async IAsyncEnumerable<XAiProjectDto> GetAllAsAsyncEnumerable(
|
||||||
|
bool ignoreSoftDeleteds = true,
|
||||||
|
Func<IQueryable<XAiProject>, IOrderedQueryable<XAiProject>> orderBuilder = null,
|
||||||
|
Func<IQueryable<XAiProject>, IIncludableQueryable<XAiProject, object>> includeBuilder = null,
|
||||||
|
bool fillConversations = true,
|
||||||
|
[EnumeratorCancellation] CancellationToken cancellationToken = default
|
||||||
|
)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
var enumerable = base.GetAllAsAsyncEnumerable(
|
||||||
|
orderBuilder: orderBuilder,
|
||||||
|
includeBuilder: includeBuilder,
|
||||||
|
ignoreSoftDeleteds: ignoreSoftDeleteds
|
||||||
|
);
|
||||||
|
await foreach (var dto in enumerable)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
if (cancellationToken.IsCancellationRequested)
|
||||||
|
{
|
||||||
|
yield break;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
await enricher.EnrichAsync(
|
||||||
|
source: dto,
|
||||||
|
destination: dto,
|
||||||
|
fillConversations: fillConversations,
|
||||||
|
cancellationToken: cancellationToken
|
||||||
|
);
|
||||||
|
yield return dto;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// find an Dto by providing a Conditional Expression ...
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="predicate"></param>
|
||||||
|
/// <param name="ignoreSoftDeleteds"></param>
|
||||||
|
/// <param name="includeBuilder"></param>
|
||||||
|
/// <param name="fillConversations"></param>
|
||||||
|
/// <param name="cancellationToken"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public virtual async Task<XAiProjectDto> FindOneAsync(
|
||||||
|
Expression<Func<XAiProject, bool>> predicate,
|
||||||
|
bool ignoreSoftDeleteds = true,
|
||||||
|
Func<IQueryable<XAiProject>, IIncludableQueryable<XAiProject, object>> includeBuilder = null,
|
||||||
|
bool fillConversations = true,
|
||||||
|
CancellationToken cancellationToken = default
|
||||||
|
)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
var result = await base.FindOneAsync(
|
||||||
|
predicate: predicate,
|
||||||
|
includeBuilder: includeBuilder,
|
||||||
|
cancellationToken: cancellationToken,
|
||||||
|
ignoreSoftDeleteds: ignoreSoftDeleteds
|
||||||
|
);
|
||||||
|
|
||||||
|
//
|
||||||
|
// Do Enrichment if result Exists ...
|
||||||
|
if (!result.IsNullOrDefault())
|
||||||
|
{
|
||||||
|
//
|
||||||
|
await enricher.EnrichAsync(
|
||||||
|
source: result,
|
||||||
|
destination: result,
|
||||||
|
fillConversations: fillConversations,
|
||||||
|
cancellationToken: cancellationToken
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// find a collection of Dtos by proving a Conditional Expression ...
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="predicate"></param>
|
||||||
|
/// <param name="ignoreSoftDeleteds"></param>
|
||||||
|
/// <param name="orderBuilder"></param>
|
||||||
|
/// <param name="includeBuilder"></param>
|
||||||
|
/// <param name="fillConversations"></param>
|
||||||
|
/// <param name="cancellationToken"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public virtual async Task<IEnumerable<XAiProjectDto>> FindManyAsync(
|
||||||
|
Expression<Func<XAiProject, bool>> predicate,
|
||||||
|
bool ignoreSoftDeleteds = true,
|
||||||
|
Func<IQueryable<XAiProject>, IOrderedQueryable<XAiProject>> orderBuilder = null,
|
||||||
|
Func<IQueryable<XAiProject>, IIncludableQueryable<XAiProject, object>> includeBuilder = null,
|
||||||
|
bool fillConversations = true,
|
||||||
|
CancellationToken cancellationToken = default
|
||||||
|
)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
var result = await base.FindManyAsync(
|
||||||
|
predicate: predicate,
|
||||||
|
orderBuilder: orderBuilder,
|
||||||
|
includeBuilder: includeBuilder,
|
||||||
|
cancellationToken: cancellationToken,
|
||||||
|
ignoreSoftDeleteds: ignoreSoftDeleteds
|
||||||
|
);
|
||||||
|
|
||||||
|
//
|
||||||
|
// Do Enrichment if result Exists ...
|
||||||
|
if (!result.IsNullOrDefault())
|
||||||
|
{
|
||||||
|
//
|
||||||
|
await enricher.EnrichRangeAsync(
|
||||||
|
sources: result,
|
||||||
|
destinations: result,
|
||||||
|
fillConversations: fillConversations,
|
||||||
|
cancellationToken: cancellationToken
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// retrieve Dtos based on XQuery Pagination structure ...
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="query"></param>
|
||||||
|
/// <param name="ignoreSoftDeleteds"></param>
|
||||||
|
/// <param name="predicate"></param>
|
||||||
|
/// <param name="orderBuilder"></param>
|
||||||
|
/// <param name="includeBuilder"></param>
|
||||||
|
/// <param name="fillConversations"></param>
|
||||||
|
/// <param name="cancellationToken"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public virtual async Task<XQueryResult<XAiProjectDto>> QueryAsync(
|
||||||
|
XQuery query,
|
||||||
|
bool ignoreSoftDeleteds = true,
|
||||||
|
Expression<Func<XAiProject, bool>> predicate = null,
|
||||||
|
Func<IQueryable<XAiProject>, IOrderedQueryable<XAiProject>> orderBuilder = null,
|
||||||
|
Func<IQueryable<XAiProject>, IIncludableQueryable<XAiProject, object>> includeBuilder = null,
|
||||||
|
bool fillConversations = true,
|
||||||
|
CancellationToken cancellationToken = default
|
||||||
|
)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
var result = await base.QueryAsync(
|
||||||
|
query: query,
|
||||||
|
predicate: predicate,
|
||||||
|
orderBuilder: orderBuilder,
|
||||||
|
includeBuilder: includeBuilder,
|
||||||
|
cancellationToken: cancellationToken,
|
||||||
|
ignoreSoftDeleteds: ignoreSoftDeleteds
|
||||||
|
);
|
||||||
|
|
||||||
|
//
|
||||||
|
// Do Enrichment if result Exists ...
|
||||||
|
if (!result.IsNullOrDefault())
|
||||||
|
{
|
||||||
|
//
|
||||||
|
await enricher.EnrichRangeAsync(
|
||||||
|
sources: result.Items,
|
||||||
|
destinations: result.Items,
|
||||||
|
fillConversations: fillConversations,
|
||||||
|
cancellationToken: cancellationToken
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
#endregion
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -147,6 +147,7 @@ namespace xAiModels.Providers.Enrichers
|
|||||||
|
|
||||||
//
|
//
|
||||||
result = await conversationTitleResourceProvider.GetResource(
|
result = await conversationTitleResourceProvider.GetResource(
|
||||||
|
owner: null,
|
||||||
identifier: title,
|
identifier: title,
|
||||||
cancellationToken: cancellationToken
|
cancellationToken: cancellationToken
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -37,6 +37,7 @@ namespace xAiModels.Providers.Enrichers
|
|||||||
// Run independent async operations concurrently
|
// Run independent async operations concurrently
|
||||||
var ownerTask = ResolveOwnerAsync(source.OwnerId, cancellationToken);
|
var ownerTask = ResolveOwnerAsync(source.OwnerId, cancellationToken);
|
||||||
var conversationTask = ResolveConversationAsync(source.ConversationId, cancellationToken);
|
var conversationTask = ResolveConversationAsync(source.ConversationId, cancellationToken);
|
||||||
|
|
||||||
//
|
//
|
||||||
// wait until All Tasks Resolved ...
|
// wait until All Tasks Resolved ...
|
||||||
await Task.WhenAll(ownerTask, conversationTask);
|
await Task.WhenAll(ownerTask, conversationTask);
|
||||||
|
|||||||
@@ -34,22 +34,90 @@ namespace xAiModels.Providers.Enrichers
|
|||||||
this.projectDescriptionResourceProvider = projectDescriptionResourceProvider;
|
this.projectDescriptionResourceProvider = projectDescriptionResourceProvider;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Task EnrichAsync(
|
public async Task EnrichAsync(
|
||||||
XAiProjectDto source,
|
XAiProjectDto source,
|
||||||
XAiProjectDto destination,
|
XAiProjectDto destination,
|
||||||
CancellationToken cancellationToken = default
|
CancellationToken cancellationToken = default
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
throw new NotImplementedException();
|
await EnrichAsync(
|
||||||
|
source: source,
|
||||||
|
destination: destination,
|
||||||
|
fillConversations: false,
|
||||||
|
cancellationToken: cancellationToken
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Task EnrichRangeAsync(
|
public async Task EnrichAsync(
|
||||||
|
XAiProjectDto source,
|
||||||
|
XAiProjectDto destination,
|
||||||
|
bool fillConversations = true,
|
||||||
|
CancellationToken cancellationToken = default
|
||||||
|
)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
// Run independent async operations concurrently
|
||||||
|
var titleTask = ResolveTitleAsync(source.Title, cancellationToken);
|
||||||
|
var ownerTask = ResolveOwnerAsync(source.OwnerId, cancellationToken);
|
||||||
|
var conversationsTask = ResolveConversationsAsync(source.Id, cancellationToken);
|
||||||
|
var descriptionTask = ResolveDescriptionAsync(source.Description, cancellationToken);
|
||||||
|
|
||||||
|
//
|
||||||
|
// wait until All Tasks Resolved ...
|
||||||
|
Task[] tasks =
|
||||||
|
{
|
||||||
|
titleTask,
|
||||||
|
ownerTask,
|
||||||
|
descriptionTask
|
||||||
|
};
|
||||||
|
if (fillConversations)
|
||||||
|
{
|
||||||
|
tasks = [.. tasks, conversationsTask];
|
||||||
|
}
|
||||||
|
await Task.WhenAll(tasks);
|
||||||
|
|
||||||
|
//
|
||||||
|
// Attached Resolved Info to Destination ...
|
||||||
|
destination.Owner = ownerTask.Result;
|
||||||
|
destination.TitleResource = titleTask.Result;
|
||||||
|
destination.DescriptionResource = descriptionTask.Result;
|
||||||
|
if (!conversationsTask.Result.IsNull())
|
||||||
|
{
|
||||||
|
destination.Conversations = [.. conversationsTask.Result];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task EnrichRangeAsync(
|
||||||
IEnumerable<XAiProjectDto> sources,
|
IEnumerable<XAiProjectDto> sources,
|
||||||
IEnumerable<XAiProjectDto> destinations,
|
IEnumerable<XAiProjectDto> destinations,
|
||||||
CancellationToken cancellationToken = default
|
CancellationToken cancellationToken = default
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
throw new NotImplementedException();
|
//
|
||||||
|
// Make Tasks Ready ...
|
||||||
|
var tasks = sources.Zip(destinations, (src, dst) =>
|
||||||
|
EnrichAsync(src, dst, cancellationToken)
|
||||||
|
);
|
||||||
|
|
||||||
|
//
|
||||||
|
await Task.WhenAll(tasks);
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task EnrichRangeAsync(
|
||||||
|
IEnumerable<XAiProjectDto> sources,
|
||||||
|
IEnumerable<XAiProjectDto> destinations,
|
||||||
|
bool fillConversations = true,
|
||||||
|
CancellationToken cancellationToken = default
|
||||||
|
)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
// Make Tasks Ready ...
|
||||||
|
var tasks = sources.Zip(destinations, (src, dst) =>
|
||||||
|
EnrichAsync(src, dst, fillConversations, cancellationToken)
|
||||||
|
);
|
||||||
|
|
||||||
|
//
|
||||||
|
await Task.WhenAll(tasks);
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
@@ -111,6 +179,7 @@ namespace xAiModels.Providers.Enrichers
|
|||||||
|
|
||||||
//
|
//
|
||||||
result = await projectTitleResourceProvider.GetResource(
|
result = await projectTitleResourceProvider.GetResource(
|
||||||
|
owner: null,
|
||||||
identifier: identifier,
|
identifier: identifier,
|
||||||
cancellationToken: cancellationToken
|
cancellationToken: cancellationToken
|
||||||
);
|
);
|
||||||
@@ -142,6 +211,7 @@ namespace xAiModels.Providers.Enrichers
|
|||||||
|
|
||||||
//
|
//
|
||||||
result = await projectDescriptionResourceProvider.GetResource(
|
result = await projectDescriptionResourceProvider.GetResource(
|
||||||
|
owner: null,
|
||||||
identifier: identifier,
|
identifier: identifier,
|
||||||
cancellationToken: cancellationToken
|
cancellationToken: cancellationToken
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -1,23 +1,21 @@
|
|||||||
using xAiModels.Constants;
|
using xAiModels.Constants;
|
||||||
using xAiModels.Interfaces;
|
using xAiModels.Interfaces;
|
||||||
|
using xCommons.Configurations;
|
||||||
using xStringService.Interfaces.Dtos;
|
using xStringService.Interfaces.Dtos;
|
||||||
using xStringService.Providers;
|
using xStringService.Providers;
|
||||||
|
|
||||||
namespace xAiModels.Providers
|
namespace xAiModels.Providers
|
||||||
{
|
{
|
||||||
public class XAiConversationTitleResourceProvider : XBaseItemResourceProvider, IXAiConversationTitleResourceProvider
|
public class XAiConversationTitleResourceProvider : XBaseOwnedItemResourceProvider, IXAiConversationTitleResourceProvider
|
||||||
{
|
{
|
||||||
public XAiConversationTitleResourceProvider(
|
public XAiConversationTitleResourceProvider(
|
||||||
|
XAppConfiguration appConfig,
|
||||||
IXStringServiceProvider stringProvider
|
IXStringServiceProvider stringProvider
|
||||||
) : base(
|
) : base(
|
||||||
|
appConfig: appConfig,
|
||||||
stringProvider: stringProvider,
|
stringProvider: stringProvider,
|
||||||
item: XAiModelsConstants.XAiConversationTitleIdentifier
|
item: XAiModelsConstants.XAiConversationTitleIdentifier
|
||||||
)
|
)
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
//
|
|
||||||
#region Actions ...
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,15 +1,18 @@
|
|||||||
using xAiModels.Constants;
|
using xAiModels.Constants;
|
||||||
using xAiModels.Interfaces;
|
using xAiModels.Interfaces;
|
||||||
|
using xCommons.Configurations;
|
||||||
using xStringService.Interfaces.Dtos;
|
using xStringService.Interfaces.Dtos;
|
||||||
using xStringService.Providers;
|
using xStringService.Providers;
|
||||||
|
|
||||||
namespace xAiModels.Providers
|
namespace xAiModels.Providers
|
||||||
{
|
{
|
||||||
public class XAiProjectDescriptionResourceProvider : XBaseItemResourceProvider, IXAiProjectDescriptionResourceProvider
|
public class XAiProjectDescriptionResourceProvider : XBaseOwnedItemResourceProvider, IXAiProjectDescriptionResourceProvider
|
||||||
{
|
{
|
||||||
public XAiProjectDescriptionResourceProvider(
|
public XAiProjectDescriptionResourceProvider(
|
||||||
|
XAppConfiguration appConfig,
|
||||||
IXStringServiceProvider stringProvider
|
IXStringServiceProvider stringProvider
|
||||||
) : base(
|
) : base(
|
||||||
|
appConfig: appConfig,
|
||||||
stringProvider: stringProvider,
|
stringProvider: stringProvider,
|
||||||
item: XAiModelsConstants.XAiProjectDescriptionIdentifier
|
item: XAiModelsConstants.XAiProjectDescriptionIdentifier
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -1,15 +1,18 @@
|
|||||||
using xAiModels.Constants;
|
using xAiModels.Constants;
|
||||||
using xAiModels.Interfaces;
|
using xAiModels.Interfaces;
|
||||||
|
using xCommons.Configurations;
|
||||||
using xStringService.Interfaces.Dtos;
|
using xStringService.Interfaces.Dtos;
|
||||||
using xStringService.Providers;
|
using xStringService.Providers;
|
||||||
|
|
||||||
namespace xAiModels.Providers
|
namespace xAiModels.Providers
|
||||||
{
|
{
|
||||||
public class XAiProjectTitleResourceProvider : XBaseItemResourceProvider, IXAiProjectTitleResourceProvider
|
public class XAiProjectTitleResourceProvider : XBaseOwnedItemResourceProvider, IXAiProjectTitleResourceProvider
|
||||||
{
|
{
|
||||||
public XAiProjectTitleResourceProvider(
|
public XAiProjectTitleResourceProvider(
|
||||||
|
XAppConfiguration appConfig,
|
||||||
IXStringServiceProvider stringProvider
|
IXStringServiceProvider stringProvider
|
||||||
) : base(
|
) : base(
|
||||||
|
appConfig: appConfig,
|
||||||
stringProvider: stringProvider,
|
stringProvider: stringProvider,
|
||||||
item: XAiModelsConstants.XAiProjectTitleIdentifier
|
item: XAiModelsConstants.XAiProjectTitleIdentifier
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user