GetLoggedInUserWithOid mit Exception, falls Oid null ist

Conversation pro ApplicationUser
This commit is contained in:
2025-04-09 10:59:23 +02:00
parent 8370f7e804
commit 29bf38d94d
6 changed files with 27 additions and 5 deletions

View File

@@ -1,5 +1,7 @@
using BeWo.Data.Access;
using BeWo.Data;
using BeWo.Data.Access;
using BeWo.Data.Entities;
using BeWo.Data.Security;
using BeWo.Service.DCEntityMapper;
using BeWo.Service.ServiceContracts;
using BeWo.Service.ServiceProxy;
@@ -67,8 +69,9 @@ namespace BeWo.Service.ServiceImplementations
public IEnumerable<AiConversationDC> GetAiConversations(int uicontext)
{
// SearchDAO
var current_user = UserRightHelper.GetLoggedInUserWithOid();
var convs = DAOFactory.GenericDAO.GetAll<AiConversation>();
var filter = convs.Where(x => x.UIContext == uicontext);
var filter = convs.Where(x => x.UIContext == uicontext && x.ApplicationUserOid == current_user.Oid);
var dcs = MapperFactory.AiConversation.MapToNewDCs(filter);
return dcs;
@@ -76,6 +79,8 @@ namespace BeWo.Service.ServiceImplementations
public AiConversationDC CreateAiConversation(int uicontext, long model, List<Tuple<long, long>> bewoobjects)
{
var current_user = UserRightHelper.GetLoggedInUserWithOid();
var system = AiSystemBuilder.CreateSystemInstructions(uicontext, bewoobjects);
var conv = new AiConversation();
@@ -85,6 +90,7 @@ namespace BeWo.Service.ServiceImplementations
conv.Modell = DAOFactory.GenericDAO.LoadByID<AiModel>(model);
conv.UIContext = uicontext;
conv.Updated = DateTime.Now;
conv.ApplicationUserOid = current_user.Oid;
var msg = new AiConversationMessage();
msg.Message = system;