From 4fe5d57d37612edac91c9486fa937fd90c41a691 Mon Sep 17 00:00:00 2001 From: Hadi Khazaee Asl Date: Wed, 11 Nov 2026 11:43:10 +0330 Subject: [PATCH] fix Create Conversation to Handle Default Project Id ... --- Interfaces/IXAiDataProvider.cs | 2 +- Providers/XAiDataProvider.cs | 26 ++++++++++++++++++++++---- 2 files changed, 23 insertions(+), 5 deletions(-) diff --git a/Interfaces/IXAiDataProvider.cs b/Interfaces/IXAiDataProvider.cs index b675559..83071e9 100644 --- a/Interfaces/IXAiDataProvider.cs +++ b/Interfaces/IXAiDataProvider.cs @@ -237,7 +237,7 @@ namespace xAiModels.Interfaces /// Task CreateConversation( string ownerId, - Guid projectId, + Guid? projectId, XAiConversationDto item = null, string connectionId = null, CancellationToken cancellationToken = default diff --git a/Providers/XAiDataProvider.cs b/Providers/XAiDataProvider.cs index 75f78ec..157498a 100644 --- a/Providers/XAiDataProvider.cs +++ b/Providers/XAiDataProvider.cs @@ -778,7 +778,7 @@ namespace xAiModels.Providers /// public async Task CreateConversation( string ownerId, - Guid projectId, + Guid? projectId, XAiConversationDto item = null, string connectionId = null, CancellationToken cancellationToken = default @@ -786,16 +786,34 @@ namespace xAiModels.Providers { // // Validate Args ... - if (projectId.IsNull() || - projectId.IsDefaultGuid()) + if (ownerId.IsNullOrEmpty()) { XException.InvalidArgs.Throw(); } + // + if (!projectId.HasValue || + projectId.Value.IsDefaultGuid()) + { + // + var defaultProject = await GetDefaultProject( + ownerId: ownerId, + connectionId: connectionId, + cancellationToken: cancellationToken + ); + if (defaultProject.IsNullOrDefault()) + { + XException.ActionFailed.Throw(); + } + + // + projectId = defaultProject.Id; + } + // // Handle Proejct ... XAiProjectDto project = await projectRepositoryService.GetAsync( - id: projectId, + id: projectId.Value, includeBuilder: null, ignoreSoftDeleteds: true, // fillConversations: false,