From bd960f1c6c53b1f33bb10c079dd04bd9c1215f11 Mon Sep 17 00:00:00 2001 From: Rene Evertz Date: Thu, 7 May 2026 15:50:21 +0200 Subject: [PATCH] Steps werden geupdatet beim Speichern --- BeWo/Services/BeWoWindowService.cs | 2 +- .../AiPromptbausteinRoutineStepVM.cs | 7 ++++ BeWo/ViewModel/AiPromptbausteinRoutineVM.cs | 5 +-- .../ListViewModel/AbstractDCListMapperVM.cs | 7 +++- .../AiPromptbausteinRoutineStepListVM.cs | 37 +++++++++++++++++++ 5 files changed, 52 insertions(+), 6 deletions(-) diff --git a/BeWo/Services/BeWoWindowService.cs b/BeWo/Services/BeWoWindowService.cs index b2070620c..fee6d373d 100644 --- a/BeWo/Services/BeWoWindowService.cs +++ b/BeWo/Services/BeWoWindowService.cs @@ -117,7 +117,7 @@ namespace BeWo.Services Height = 400, Width = 600 }; - Show("KI Promptbaustein Prompt", control, viewModel, options); + Show("KI Promptbaustein Routine", control, viewModel, options); } public void ShowAiPromptbausteinActionResultWindow(AiPromptbausteinActionResultViewModel viewModel) { diff --git a/BeWo/ViewModel/AiPromptbausteinRoutineStepVM.cs b/BeWo/ViewModel/AiPromptbausteinRoutineStepVM.cs index 9fb51bcb9..4cf4660bf 100644 --- a/BeWo/ViewModel/AiPromptbausteinRoutineStepVM.cs +++ b/BeWo/ViewModel/AiPromptbausteinRoutineStepVM.cs @@ -50,5 +50,12 @@ namespace BeWo.ViewModel return pDataContract; } + + public override void UpdateByDataContract(AiPromptbausteinRoutineStepDC pDataContract) + { + Position = pDataContract.Position; + PromptReference = pDataContract.PromptReference; + ReferenceVersion = pDataContract.ReferenceVersion; + } } } diff --git a/BeWo/ViewModel/AiPromptbausteinRoutineVM.cs b/BeWo/ViewModel/AiPromptbausteinRoutineVM.cs index fe8bf9f83..bc7c5324a 100644 --- a/BeWo/ViewModel/AiPromptbausteinRoutineVM.cs +++ b/BeWo/ViewModel/AiPromptbausteinRoutineVM.cs @@ -131,10 +131,7 @@ namespace BeWo.ViewModel IsPublic = pDataContract.IsPublic; IsFavorite = pDataContract.IsFavorite; - var steps = new AiPromptbausteinRoutineStepListVM(pDataContract.Steps); - - Steps.VMList.Clear(); - Steps.VMList.AddRange(steps.VMList); + Steps.UpdateByDataContracts(pDataContract.Steps); } } } diff --git a/BeWo/ViewModel/ListViewModel/AbstractDCListMapperVM.cs b/BeWo/ViewModel/ListViewModel/AbstractDCListMapperVM.cs index 41b8e3513..63cd9954d 100644 --- a/BeWo/ViewModel/ListViewModel/AbstractDCListMapperVM.cs +++ b/BeWo/ViewModel/ListViewModel/AbstractDCListMapperVM.cs @@ -291,5 +291,10 @@ namespace BeWo.ViewModel.ListViewModel { return null; } - } + + public virtual void UpdateByDataContracts(List pDataContracts) + { + throw new NotImplementedException(); + } + } } \ No newline at end of file diff --git a/BeWo/ViewModel/ListViewModel/AiPromptbausteinRoutineStepListVM.cs b/BeWo/ViewModel/ListViewModel/AiPromptbausteinRoutineStepListVM.cs index dbb66b835..d1649157f 100644 --- a/BeWo/ViewModel/ListViewModel/AiPromptbausteinRoutineStepListVM.cs +++ b/BeWo/ViewModel/ListViewModel/AiPromptbausteinRoutineStepListVM.cs @@ -4,6 +4,7 @@ using System.Linq; using System.Text; using System.Threading.Tasks; using BS.Shared.DataContracts.Feature.AI; +using BS.Shared.Extensions; namespace BeWo.ViewModel.ListViewModel { @@ -13,5 +14,41 @@ namespace BeWo.ViewModel.ListViewModel { } + + public override void UpdateByDataContracts(List pDataContracts) + { + var count_a = Count; + var count_b = pDataContracts.Count; + + // 1-k updaten + var count_toupdate = Math.Min(count_a, count_b); + for ( var i = 0; i < count_toupdate; i++) + { + var a = VMList[i]; + var b = pDataContracts[i]; + + a.UpdateByDataContract(b); + } + + if (count_a == count_b) + return; + + if(count_a > count_b) + { + for (var i = count_a - 1; i > count_toupdate - 1; i--) + { + VMList.RemoveAt(i); + } + } + else + { + for (int i = count_toupdate; i < count_b; i++) + { + var dc = pDataContracts[i]; + var vm = new AiPromptbausteinRoutineStepVM(dc); + VMList.Add(vm); + } + } + } } } \ No newline at end of file