104 lines
3.0 KiB
C#
104 lines
3.0 KiB
C#
using xCommons.Extensions;
|
|
using System.Collections.Generic;
|
|
using xAiApi.AI.Models.Entities;
|
|
using xAiModels.Models;
|
|
|
|
namespace xAiApi.AI.Extensions
|
|
{
|
|
/// <summary>
|
|
/// Extensions which used for AiModels ...
|
|
/// </summary>
|
|
public static class AiModelsExtensions
|
|
{
|
|
/// <summary>
|
|
/// Converts Entity to Dto regardsless of Owner and NavigationProperties ...
|
|
/// </summary>
|
|
/// <param name="source"></param>
|
|
/// <returns></returns>
|
|
public static XAiMessageDto ToDto(this XAiMessage source)
|
|
{
|
|
//
|
|
XAiMessageDto result = null;
|
|
|
|
//
|
|
if (!source.IsNullOrDefault())
|
|
{
|
|
//
|
|
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),
|
|
}
|
|
);
|
|
}
|
|
|
|
//
|
|
return result;
|
|
}
|
|
}
|
|
} |