From 3969719275d62e94033c294efd4687f866e5f6df Mon Sep 17 00:00:00 2001 From: Kojo Date: Mon, 8 Dec 2025 21:03:06 +0100 Subject: [PATCH] Promptbaustein-Services, mit und ohne Tree --- BeWo/ViewModel/VMFactory.cs | 2 +- Service/Plugins/AiPromptbausteineService.cs | 44 +++++++++++++++++-- .../Enhanced/AiEnhancedServiceImp.cs | 4 +- 3 files changed, 44 insertions(+), 6 deletions(-) diff --git a/BeWo/ViewModel/VMFactory.cs b/BeWo/ViewModel/VMFactory.cs index d94c3f681..2d2a94f00 100644 --- a/BeWo/ViewModel/VMFactory.cs +++ b/BeWo/ViewModel/VMFactory.cs @@ -945,7 +945,7 @@ namespace BeWo.ViewModel internal static void CreateAiPromptbausteinTreeListAsync(Action get_viewmodel) { ServiceFacade.DoAiEnhancedServiceAsnyc( - req => req.GetAiPromptbausteine(), + req => req.GetAiPromptbausteineTree(), res => get_viewmodel(new AiPromptbausteinTreeListVM(res))); } } diff --git a/Service/Plugins/AiPromptbausteineService.cs b/Service/Plugins/AiPromptbausteineService.cs index 3cd969573..79bb86db1 100644 --- a/Service/Plugins/AiPromptbausteineService.cs +++ b/Service/Plugins/AiPromptbausteineService.cs @@ -2,6 +2,7 @@ using BeWo.Data.Entities; using BeWo.Service.Core; using BeWo.Service.DCEntityMapper; +using BS.Shared.DataContracts; using BS.Shared.DataContracts.Feature.AI; using BS.Shared.Extensions; using System; @@ -12,7 +13,14 @@ namespace BeWo.Service.Plugins { public class AiPromptbausteineService { - public IEnumerable GetAiPromptbausteine() + public IEnumerable GetAiPromptbausteine() + { + var allAiPromptbausteine = DAOFactory.GenericDAO.GetAll(); + var dcs = MapperFactory.AiPromptbausteinDC_AiPromptbaustein.CreateDcList(allAiPromptbausteine); + return dcs; + } + + public IEnumerable GetAiPromptbausteineTree() { var allAiPromptbausteine = DAOFactory.GenericDAO.GetAll(); var dcs = MapperFactory.AiPromptbausteinTree.MapToNewDCs(allAiPromptbausteine); @@ -22,7 +30,7 @@ namespace BeWo.Service.Plugins return predefined.GetFullPromptbausteineTree(); } - public IEnumerable CreateAiPromptbausteine(IEnumerable aiPromptbausteinDCs) + public IEnumerable CreateAiPromptbausteineTree(IEnumerable aiPromptbausteinDCs) { var aiPromptbausteine = MapperFactory.AiPromptbausteinTree.MapToNewEntities(aiPromptbausteinDCs); @@ -33,7 +41,18 @@ namespace BeWo.Service.Plugins return dcs; } - public Dictionary UpdateAiPromptbausteine(IEnumerable aiPromptbausteinDCs) + public IEnumerable CreateAiPromptbausteine(IEnumerable aiPromptbausteinDCs) + { + var aiPromptbausteine = MapperFactory.AiPromptbausteinDC_AiPromptbaustein.MapToNewEntities(aiPromptbausteinDCs); + + DAOFactory.GenericDAO.Insert(aiPromptbausteine); + + var dcs = MapperFactory.AiPromptbausteinDC_AiPromptbaustein.MapToNewDCs(aiPromptbausteine); + + return dcs; + } + + public Dictionary UpdateAiPromptbausteineTree(IEnumerable aiPromptbausteinDCs) { var aiPromptbausteine = MapperFactory.AiPromptbausteinTree.MapToNewEntities(aiPromptbausteinDCs); @@ -52,6 +71,25 @@ namespace BeWo.Service.Plugins throw new System.NotImplementedException(); } + public Dictionary UpdateAiPromptbausteine(IEnumerable aiPromptbausteinDCs) + { + var aiPromptbausteine = MapperFactory.AiPromptbausteinDC_AiPromptbaustein.MapToNewEntities(aiPromptbausteinDCs); + + /* + var originale = DAOFactory.GenericDAO.LoadByIDs(aiPromptbausteinDCs.Select(sc => sc.Oid.Value)); + foreach (var item in aiPromptbausteinDCs) + { + item.ActivationType = ActivationTypeId.Active; + } + MapperFactory.AiPromptbausteinTree.MergeWithEntitys(aiPromptbausteinDCs, originale); + */ + + DAOFactory.GenericDAO.Update(aiPromptbausteine); + + // todo: dictionary erstellen + throw new System.NotImplementedException(); + } + public void DeleteAiPromptbausteine(Dictionary oid2version) { try diff --git a/Service/ServiceImplementations/Enhanced/AiEnhancedServiceImp.cs b/Service/ServiceImplementations/Enhanced/AiEnhancedServiceImp.cs index de6e4456d..eebe1a4fa 100644 --- a/Service/ServiceImplementations/Enhanced/AiEnhancedServiceImp.cs +++ b/Service/ServiceImplementations/Enhanced/AiEnhancedServiceImp.cs @@ -68,8 +68,8 @@ namespace BeWo.Service.ServiceImplementations.Enhanced public IEnumerable GetAiPromptbausteine() => GetAiPromptbausteineService().GetAiPromptbausteine(); - public IEnumerable CreateAiPromptbausteine(IEnumerable aiPromptbausteinDC) - => GetAiPromptbausteineService().CreateAiPromptbausteine(aiPromptbausteinDC); + public IEnumerable CreateAiPromptbausteine(IEnumerable aiPromptbausteinDCs) + => GetAiPromptbausteineService().CreateAiPromptbausteine(aiPromptbausteinDCs); public Dictionary UpdateAiPromptbausteine(IEnumerable aiPromptbausteinDCs) => GetAiPromptbausteineService().UpdateAiPromptbausteine(aiPromptbausteinDCs);