/// <summary> /// Initializes a new instance of the <see cref="ProcessViewSectionViewModel"/> class. /// </summary> /// <param name="model">The model.</param> /// <param name="parentViewModel">The parent view model.</param> public ProcessViewSectionViewModel(ProcessViewSectionEdit model, ProcessViewViewModel parentViewModel, bool composeParts = true) { if (composeParts) Ioc.ComposeParts(this); Parent = parentViewModel; Fields = new ObservableCollection<ProcessViewFieldViewModel>(); Steps = new ObservableCollection<IProcessViewSectionStepViewModel>(); SetModel(model); }
/// <summary> /// Sets the model. /// </summary> /// <param name="model">The model.</param> private void SetModel(ProcessViewSectionEdit model) { Model = model; if (ProcessViewManager != null) Model.ShowFieldList = ProcessViewManager.ShowFields(Model.TemplateSectionGuid); Fields.Clear(); if (Model != null) { foreach (var field in Model.FieldList) { var viewModel = new ProcessViewFieldViewModel(field, this); Fields.Add(viewModel); } foreach (var stepEdit in Model.StepList) { var stepVmExport = StepViewModels.FirstOrDefault(vm => vm.Metadata.StepType == stepEdit.GetType()); if (stepVmExport != null) { var stepVm = stepVmExport.CreateExport().Value; stepVm.Init(stepEdit, this); Steps.Add(stepVm); } } } }