56 lines
1.3 KiB
C#
56 lines
1.3 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using BS.Shared.DataContracts.Feature.AI;
|
|
using BS.Shared.Extensions;
|
|
|
|
namespace BeWo.ViewModel.ListViewModel
|
|
{
|
|
public class AiPromptbausteinRoutineStepListVM : AbstractDCListMapperVM<AiPromptbausteinRoutineStepDC, AiPromptbausteinRoutineStepVM>
|
|
{
|
|
public AiPromptbausteinRoutineStepListVM(IEnumerable<AiPromptbausteinRoutineStepDC> pDataContracts = null) : base(pDataContracts)
|
|
{
|
|
|
|
}
|
|
|
|
public override void UpdateByDataContracts(List<AiPromptbausteinRoutineStepDC> 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);
|
|
}
|
|
}
|
|
|
|
FirePropertyChanged(nameof(Count));
|
|
}
|
|
}
|
|
} |