This commit is contained in:
2026-04-24 13:42:14 +03:30
parent 5efd41754a
commit e49c273171
9 changed files with 643 additions and 171 deletions
+85 -6
View File
@@ -1,21 +1,100 @@
using xCommons.Extensions;
using System.Collections.Generic;
using Microsoft.Extensions.AI;
using System.Linq;
using xAiApi.AI.Models.Entities;
using xAiModels.Models;
namespace xAiApi.AI.Extensions
{
/// <summary>
/// Extensions which used for AiModels ...
/// </summary>
public static class AiModelsExtensions
{
public static AIContent GetLast(IList<AIContent> source)
/// <summary>
/// Converts Entity to Dto regardsless of Owner and NavigationProperties ...
/// </summary>
/// <param name="source"></param>
/// <returns></returns>
public static XAiMessageDto ToDto(this XAiMessage source)
{
//
AIContent result = null;
XAiMessageDto result = null;
//
if (source.HasChild())
if (!source.IsNullOrDefault())
{
result = source.ElementAt(source.Count - 1);
//
result = new XAiMessageDto();
result = result.UpdateData(
updateWith: source,
propertyBlackList: new List<string>
{
nameof(XAiMessage.Deleted),
nameof(XAiMessageDto.Owner),
nameof(XAiMessage.Conversation),
}
);
}
//
return result;
}
/// <summary>
/// Converts Entity to Dto regardsless of Owner and NavigationProperties ...
/// </summary>
/// <param name="source"></param>
/// <returns></returns>
public static XAiProjectDto ToDto(this XAiProject source)
{
//
XAiProjectDto result = null;
//
if (!source.IsNullOrDefault())
{
//
result = new XAiProjectDto();
result = result.UpdateData(
updateWith: source,
propertyBlackList: new List<string>
{
nameof(XAiProject.Deleted),
nameof(XAiProjectDto.Owner),
nameof(XAiProject.Conversations),
}
);
}
//
return result;
}
/// <summary>
/// Converts Entity to Dto regardsless of Owner and NavigationProperties ...
/// </summary>
/// <param name="source"></param>
/// <returns></returns>
public static XAiConversationDto ToDto(this XAiConversation source)
{
//
XAiConversationDto result = null;
//
if (!source.IsNullOrDefault())
{
//
result = new XAiConversationDto();
result = result.UpdateData(
updateWith: source,
propertyBlackList: new List<string>
{
nameof(XAiConversation.Deleted),
nameof(XAiConversation.Project),
nameof(XAiConversationDto.Owner),
nameof(XAiConversation.Messages),
}
);
}
//