Exemplo n.º 1
0
        private BookRelationVM SelectRelation(BookRelation selectedRelationModel)
        {
            BookRelationType type       = BookRelationType.Abstract;
            string           metaDataId = null;

            if (selectedRelationModel != null)
            {
                type       = selectedRelationModel.BookRelationType;
                metaDataId = selectedRelationModel.MetadataId;
            }
            SelectMetaDataWindowVM vm = new SelectMetaDataWindowVM(type, metaDataId)
            {
                Parent = this
            };

            vm.Init();
            SelectMetaDataWindow window = new SelectMetaDataWindow(vm);

            window.Owner = Window;
            BookRelationVM relation = null;

            if (window.ShowDialog() == true)
            {
                BookRelation relationModel = new BookRelation();
                relationModel.BookRelationType = vm.BookRelationType;
                ITitleProvider selectedObject = vm.SelectedObject as ITitleProvider;
                if (selectedObject != null)
                {
                    relationModel.MetadataId = selectedObject.Id;
                }
                relation = FindExistRelation(relationModel);
                if (relation == null)
                {
                    relation = CreateRelation(relationModel);
                }
            }
            return(relation);
        }
Exemplo n.º 2
0
 private BookRelationVM SelectRelation(BookRelation selectedRelationModel)
 {
     BookRelationType type = BookRelationType.Abstract;
     string metaDataId = null;
     if (selectedRelationModel != null)
     {
         type = selectedRelationModel.BookRelationType;
         metaDataId = selectedRelationModel.MetadataId;
     }
     SelectMetaDataWindowVM vm = new SelectMetaDataWindowVM(type, metaDataId) { Parent = this };
     vm.Init();
     SelectMetaDataWindow window = new SelectMetaDataWindow(vm);
     window.Owner = Window;
     BookRelationVM relation = null;
     if (window.ShowDialog() == true)
     {
         BookRelation relationModel = new BookRelation();
         relationModel.BookRelationType = vm.BookRelationType;
         ITitleProvider selectedObject = vm.SelectedObject as ITitleProvider;
         if (selectedObject != null)
         {
             relationModel.MetadataId = selectedObject.Id;
         }
         relation = FindExistRelation(relationModel);
         if (relation == null)
         {
             relation = CreateRelation(relationModel);
         }
     }
     return relation;
 }