Example #1
0
        public Document FirstDocument(PLMPackEntities db)
        {
            TreeNodeDocument treeNodeDoc = db.TreeNodeDocuments.Single(tnd => tnd.TreeNodeId == this.Id);

            return(db.Documents.Single(d => d.Id == treeNodeDoc.DocumentId));

            /*
             * get
             * {
             *  if (TreeNodeDocuments.Count > 0)
             *      return TreeNodeDocuments.First().Document;
             *  else
             *      return null;
             * }
             */
        }
Example #2
0
        public TreeNode InsertDocument(PLMPackEntities db, string grpId
                                       , string name, string description
                                       , string docType, Guid docGuid, string docExt
                                       , Thumbnail thumb)
        {
            // create TreeNode
            TreeNode tn = InsertBranch(db, grpId, name, description, thumb);
            // create document
            Document doc = Document.CreateNew(db, grpId
                                              , docType
                                              , name, description
                                              , docGuid, docExt);
            // create treeNode document
            TreeNodeDocument tnd = new TreeNodeDocument();

            tnd.TreeNodeId = tn.Id;
            tnd.DocumentId = doc.Id;
            db.TreeNodeDocuments.Add(tnd);
            db.SaveChanges();

            return(TreeNode.GetById(db, Guid.Parse(tn.Id)));
        }