last ...
This commit is contained in:
@@ -1,8 +1,12 @@
|
|||||||
|
using System;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using xAiModels.Models;
|
using xAiModels.Models;
|
||||||
using xCommons.Extensions;
|
using xCommons.Extensions;
|
||||||
|
using xAiModels.Constants;
|
||||||
using xAiModels.Models.Dtos;
|
using xAiModels.Models.Dtos;
|
||||||
|
using xExceptions.Constants;
|
||||||
using xAiModels.Models.Entities;
|
using xAiModels.Models.Entities;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
namespace xAiModels.Extensions
|
namespace xAiModels.Extensions
|
||||||
{
|
{
|
||||||
@@ -172,5 +176,164 @@ namespace xAiModels.Extensions
|
|||||||
//
|
//
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Check a Collection Contains Default Project for Specified Owner or not ...
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="source"></param>
|
||||||
|
/// <param name="ownerId"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static bool HasDefaultProject(
|
||||||
|
this IEnumerable<XAiProjectDto> source,
|
||||||
|
string ownerId
|
||||||
|
)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
// Validate Args ...
|
||||||
|
if (source.HasChild() ||
|
||||||
|
ownerId.IsNullOrEmpty())
|
||||||
|
{
|
||||||
|
XException.InvalidArgs.Throw();
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
var item = source
|
||||||
|
.FirstOrDefault(x =>
|
||||||
|
x.Title
|
||||||
|
.ToNormalString()
|
||||||
|
.Contains(ownerId.ToNormalString()) &&
|
||||||
|
x.Title
|
||||||
|
.ToNormalString()
|
||||||
|
.Contains(XAiModelsConstants.DefaultXAiProjectDescriptionResourceID)
|
||||||
|
);
|
||||||
|
|
||||||
|
//
|
||||||
|
var result = !item.IsNullOrDefault();
|
||||||
|
|
||||||
|
//
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Check a Collection Contains Default Conversation for Specified Project or not ...
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="source"></param>
|
||||||
|
/// <param name="ownerId"></param>
|
||||||
|
/// <param name="projectId"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static bool HasDefaultConversation(
|
||||||
|
this IEnumerable<XAiConversationDto> source,
|
||||||
|
string ownerId,
|
||||||
|
Guid projectId
|
||||||
|
)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
// Validate Args ...
|
||||||
|
if (source.HasChild() ||
|
||||||
|
projectId.IsDefaultGuid())
|
||||||
|
{
|
||||||
|
XException.InvalidArgs.Throw();
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
var item = source
|
||||||
|
.FirstOrDefault(x =>
|
||||||
|
x.Title
|
||||||
|
.ToNormalString()
|
||||||
|
.Contains(ownerId.ToNormalString()) &&
|
||||||
|
x.Title
|
||||||
|
.ToNormalString()
|
||||||
|
.Contains(projectId.ToString().ToNormalString()) &&
|
||||||
|
x.Title
|
||||||
|
.ToNormalString()
|
||||||
|
.Contains(XAiModelsConstants.DefaultXAiConversationTitleResourceID)
|
||||||
|
);
|
||||||
|
|
||||||
|
//
|
||||||
|
var result = !item.IsNullOrDefault();
|
||||||
|
|
||||||
|
//
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Retrieve Default Project Id from a Collection ...
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="source"></param>
|
||||||
|
/// <param name="ownerId"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static Guid GetDafualtProject(
|
||||||
|
this IEnumerable<XAiProjectDto> source,
|
||||||
|
string ownerId
|
||||||
|
)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
// Validate Args ...
|
||||||
|
if (source.HasChild() ||
|
||||||
|
ownerId.IsNullOrEmpty())
|
||||||
|
{
|
||||||
|
XException.InvalidArgs.Throw();
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
var item = source
|
||||||
|
.FirstOrDefault(x =>
|
||||||
|
x.Title
|
||||||
|
.ToNormalString()
|
||||||
|
.Contains(ownerId.ToNormalString()) &&
|
||||||
|
x.Title
|
||||||
|
.ToNormalString()
|
||||||
|
.Contains(XAiModelsConstants.DefaultXAiProjectDescriptionResourceID)
|
||||||
|
);
|
||||||
|
if (item.IsNullOrDefault())
|
||||||
|
{
|
||||||
|
XException.NotFound.Throw();
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
return item.Id;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Get Default Conversation Id from a Collection Contains ...
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="source"></param>
|
||||||
|
/// <param name="ownerId"></param>
|
||||||
|
/// <param name="projectId"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static Guid GetDefaultConversation(
|
||||||
|
this IEnumerable<XAiConversationDto> source,
|
||||||
|
string ownerId,
|
||||||
|
Guid projectId
|
||||||
|
)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
// Validate Args ...
|
||||||
|
if (source.HasChild() ||
|
||||||
|
projectId.IsDefaultGuid())
|
||||||
|
{
|
||||||
|
XException.InvalidArgs.Throw();
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
var item = source
|
||||||
|
.FirstOrDefault(x =>
|
||||||
|
x.Title
|
||||||
|
.ToNormalString()
|
||||||
|
.Contains(ownerId.ToNormalString()) &&
|
||||||
|
x.Title
|
||||||
|
.ToNormalString()
|
||||||
|
.Contains(projectId.ToString().ToNormalString()) &&
|
||||||
|
x.Title
|
||||||
|
.ToNormalString()
|
||||||
|
.Contains(XAiModelsConstants.DefaultXAiConversationTitleResourceID)
|
||||||
|
);
|
||||||
|
|
||||||
|
//
|
||||||
|
var result = item.Id;
|
||||||
|
|
||||||
|
//
|
||||||
|
return result;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -104,11 +104,9 @@ namespace xAiModels.Providers
|
|||||||
var result = await projectRepositoryService.FindManyAsync(
|
var result = await projectRepositoryService.FindManyAsync(
|
||||||
includeBuilder: null,
|
includeBuilder: null,
|
||||||
ignoreSoftDeleteds: true,
|
ignoreSoftDeleteds: true,
|
||||||
// fillConversations: fillConversations,
|
|
||||||
predicate: x => x.OwnerId == ownerId,
|
predicate: x => x.OwnerId == ownerId,
|
||||||
cancellationToken: cancellationToken,
|
cancellationToken: cancellationToken,
|
||||||
orderBuilder: x => x.OrderBy(y => y.CreatedOn)
|
orderBuilder: x => x.OrderBy(y => y.CreatedOn)
|
||||||
// fillConversationMessages: fillConversationMessages
|
|
||||||
);
|
);
|
||||||
|
|
||||||
//
|
//
|
||||||
@@ -142,7 +140,6 @@ namespace xAiModels.Providers
|
|||||||
var result = await conversationRepositoryService.FindManyAsync(
|
var result = await conversationRepositoryService.FindManyAsync(
|
||||||
includeBuilder: null,
|
includeBuilder: null,
|
||||||
ignoreSoftDeleteds: false,
|
ignoreSoftDeleteds: false,
|
||||||
// fillMessages: fillMessages,
|
|
||||||
cancellationToken: cancellationToken,
|
cancellationToken: cancellationToken,
|
||||||
predicate: x => x.ProjectId == projectId,
|
predicate: x => x.ProjectId == projectId,
|
||||||
orderBuilder: x => x.OrderBy(y => y.CreatedOn)
|
orderBuilder: x => x.OrderBy(y => y.CreatedOn)
|
||||||
@@ -727,8 +724,6 @@ namespace xAiModels.Providers
|
|||||||
id: project.Id,
|
id: project.Id,
|
||||||
includeBuilder: null,
|
includeBuilder: null,
|
||||||
ignoreSoftDeleteds: true,
|
ignoreSoftDeleteds: true,
|
||||||
// fillConversations: false,
|
|
||||||
// fillConversationMessages: false,
|
|
||||||
cancellationToken: cancellationToken
|
cancellationToken: cancellationToken
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -744,7 +739,7 @@ namespace xAiModels.Providers
|
|||||||
predicate: x =>
|
predicate: x =>
|
||||||
x.ResourceTitle
|
x.ResourceTitle
|
||||||
.ToNormalString()
|
.ToNormalString()
|
||||||
.Contains(ownerId.ToNormalString()) &&
|
.Contains(projectId.ToString().ToNormalString()) &&
|
||||||
x.ResourceTitle
|
x.ResourceTitle
|
||||||
.ToNormalString()
|
.ToNormalString()
|
||||||
.Contains(XAiModelsConstants.XAiConversationTitleIdentifier
|
.Contains(XAiModelsConstants.XAiConversationTitleIdentifier
|
||||||
@@ -819,8 +814,6 @@ namespace xAiModels.Providers
|
|||||||
id: project.Id,
|
id: project.Id,
|
||||||
includeBuilder: null,
|
includeBuilder: null,
|
||||||
ignoreSoftDeleteds: true,
|
ignoreSoftDeleteds: true,
|
||||||
// fillConversations: false,
|
|
||||||
// fillConversationMessages: false,
|
|
||||||
cancellationToken: cancellationToken
|
cancellationToken: cancellationToken
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user