152 lines
4.2 KiB
C#
152 lines
4.2 KiB
C#
using System;
|
|
using System.Linq;
|
|
using BeWo.ViewModel.ListViewModel;
|
|
using BS.Shared;
|
|
using BS.Shared.DataContracts;
|
|
using BS.Shared.DataContracts.Compact;
|
|
using BS.Shared.DataContracts.Feature.AI;
|
|
using BS.Shared.Extensions;
|
|
|
|
namespace BeWo.ViewModel
|
|
{
|
|
public class AiPromptbausteinRoutineVM : AbstractDCMapperVM<AiPromptbausteinRoutineDC>
|
|
{
|
|
private string _Title;
|
|
private string _Description;
|
|
private long? _ParentFolderOid;
|
|
private CompactEmployeeDC _Creator;
|
|
private bool _IsPublic;
|
|
private int _Position;
|
|
private bool _IsFavorite;
|
|
private AiActionType _ActionType;
|
|
private AiRoutineType _RoutineType;
|
|
private bool _CanEdit;
|
|
private AiPromptbausteinRoutineStepListVM _Steps;
|
|
|
|
public AiPromptbausteinRoutineVM(AiPromptbausteinRoutineDC dc) : base(dc, dc.Oid)
|
|
{
|
|
|
|
}
|
|
|
|
public string Title
|
|
{
|
|
get => _Title;
|
|
set => SetProperty(ref _Title, value, nameof(Title), () => DataContract.Title);
|
|
}
|
|
|
|
public string Description
|
|
{
|
|
get => _Description;
|
|
set => SetProperty(ref _Description, value, nameof(Description), () => DataContract.Description);
|
|
}
|
|
|
|
public long? ParentFolderOid
|
|
{
|
|
get => _ParentFolderOid;
|
|
set => SetProperty(ref _ParentFolderOid, value, nameof(ParentFolderOid), () => DataContract.ParentFolderOid);
|
|
}
|
|
|
|
public CompactEmployeeDC Creator
|
|
{
|
|
get => _Creator;
|
|
set => SetProperty(ref _Creator, value, nameof(Creator), () => DataContract.Creator);
|
|
}
|
|
|
|
public bool IsPublic
|
|
{
|
|
get => _IsPublic;
|
|
set => SetProperty(ref _IsPublic, value, nameof(IsPublic), () => DataContract.IsPublic);
|
|
}
|
|
|
|
public int Position
|
|
{
|
|
get => _Position;
|
|
set => SetProperty(ref _Position, value, nameof(Position), () => DataContract.Position);
|
|
}
|
|
|
|
public bool IsFavorite
|
|
{
|
|
get => _IsFavorite;
|
|
set => SetProperty(ref _IsFavorite, value, nameof(IsFavorite), () => DataContract.IsFavorite);
|
|
}
|
|
|
|
public AiActionType ActionType
|
|
{
|
|
get => _ActionType;
|
|
set => SetProperty(ref _ActionType, value, nameof(ActionType), () => DataContract.ActionType);
|
|
}
|
|
|
|
public AiRoutineType RoutineType
|
|
{
|
|
get => _RoutineType;
|
|
set => SetProperty(ref _RoutineType, value, nameof(RoutineType), () => DataContract.RoutineType);
|
|
}
|
|
|
|
public bool CanEdit
|
|
{
|
|
get => _CanEdit;
|
|
set => SetProperty(ref _CanEdit, value, nameof(CanEdit), () => DataContract.CanEdit);
|
|
}
|
|
|
|
public AiPromptbausteinRoutineStepListVM Steps
|
|
{
|
|
get => _Steps;
|
|
set => SetProperty(ref _Steps, value, nameof(Steps));
|
|
}
|
|
|
|
public string FavoritenHeader => IsFavorite ? "Favorit entfernen" : "Favorit hinzufügen";
|
|
|
|
public override bool IsDirty => base.IsDirty || Steps.IsDirty;
|
|
public bool IsValid
|
|
{
|
|
get => Steps.Count > 0 && Steps.VMList.All(x => x.IsValid);
|
|
}
|
|
|
|
protected override void InitByDataContract(AiPromptbausteinRoutineDC pDataContract)
|
|
{
|
|
_Title = pDataContract.Title;
|
|
_Description = pDataContract.Description;
|
|
_ParentFolderOid = pDataContract.ParentFolderOid;
|
|
_Creator = pDataContract.Creator;
|
|
_IsPublic = pDataContract.IsPublic;
|
|
_Position = pDataContract.Position;
|
|
_IsFavorite = pDataContract.IsFavorite;
|
|
_ActionType = pDataContract.ActionType;
|
|
_RoutineType = pDataContract.RoutineType;
|
|
_CanEdit = pDataContract.CanEdit;
|
|
|
|
_Steps = new AiPromptbausteinRoutineStepListVM(pDataContract.Steps);
|
|
}
|
|
|
|
protected override AiPromptbausteinRoutineDC MapToDataContract(AiPromptbausteinRoutineDC pDataContract, bool doCommit)
|
|
{
|
|
pDataContract.Title = _Title;
|
|
pDataContract.Description = _Description;
|
|
pDataContract.ParentFolderOid = _ParentFolderOid;
|
|
pDataContract.Creator = _Creator;
|
|
pDataContract.IsPublic = _IsPublic;
|
|
pDataContract.Position = _Position;
|
|
pDataContract.IsFavorite = _IsFavorite;
|
|
pDataContract.ActionType = _ActionType;
|
|
pDataContract.RoutineType = _RoutineType;
|
|
pDataContract.CanEdit = _CanEdit;
|
|
pDataContract.Steps = _Steps.CopyToDCList(true);
|
|
|
|
return pDataContract;
|
|
}
|
|
|
|
public override void UpdateByDataContract(AiPromptbausteinRoutineDC pDataContract)
|
|
{
|
|
DataContract = pDataContract;
|
|
|
|
Title = pDataContract.Title;
|
|
Description = pDataContract.Description;
|
|
IsPublic = pDataContract.IsPublic;
|
|
IsFavorite = pDataContract.IsFavorite;
|
|
RoutineType = pDataContract.RoutineType;
|
|
|
|
Steps.UpdateByDataContracts(pDataContract.Steps);
|
|
}
|
|
}
|
|
}
|