public BuilderViewModel(Action onClose, IWindowFactory windowFactory, IBillOfMaterial sourceBillOfMaterial, IBillOfMaterial targetBillOfMaterial, UnitOfWork unitOfWork) : base(onClose)
        {
            // Get window.
            _windowFactory = windowFactory;
            _unitOfWork    = unitOfWork;

            SourceBillOfMaterial = sourceBillOfMaterial;
            TargetBillOfMaterial = targetBillOfMaterial;

            SyncSourceQuantities(TargetBillOfMaterial.ItemViewModels);

            SourceHierarchyDataGrid = new HierarchyDataGrid(SourceBillOfMaterial.ItemViewModels);
            TargetHierarchyDataGrid = new HierarchyDataGrid(TargetBillOfMaterial.ItemViewModels);

            AddItemToTargetByButtonCommand      = new RelayCommand(o => AddByButton(), o => CanAddByButton());
            RemoveItemFromTargetByButtonCommand = new RelayCommand(o => RemoveByButton(), o => CanRemoveByButton());

            AddSelectedItemInSource = new RelayCommand(o => AddRemoveSelectedItemIfValid(_selectedItemInSource), o => _selectedItemInSource != null);
            AddSelectedItemInTarget = new RelayCommand(o => AddRemoveSelectedItemIfValid(_selectedItemInTarget), o => _selectedItemInTarget != null);

            ShowCancelDialogCommand         = new RelayCommand(CancelDialog, o => true);
            HideSourceViewCommand           = new RelayCommand(o => IsSourceViewHidden = true, o => IsSourceViewHidden == false);
            ShowSourceViewCommand           = new RelayCommand(o => IsSourceViewHidden = false, o => IsSourceViewHidden == true);
            SaveTargetBillOfMaterialCommand = new RelayCommand(SaveTargetOnSaveCommand, o => true);

            CalculateInfo();
        }
 private int SynchronizeSelectedItems(DataGridItem selected, HierarchyDataGrid otherDataGrid)
 {
     return(otherDataGrid.DataGridItems.IndexOf(otherDataGrid.DataGridItems.Where(x => x.ItemViewModel.ID == selected.ItemViewModel.ID && x.Level == selected.Level).FirstOrDefault()));
 }