Exemple #1
0
        public void Delete(PLMPackEntities db, AspNetUser user)
        {
            if (!user.Groups.Contains(Group))
            {
                throw new ModelException(string.Format("User {0} is not allowed to perform this operation.", user.UserName));
            }
            // remove childrens
            List <TreeNode> childList = new List <TreeNode>(Childrens);

            childList.ForEach(tn => tn.Delete(db, user));
            // remove TreeNodeDocument
            List <TreeNodeDocument> lTreeNodeDocs = new List <TreeNodeDocument>(db.TreeNodeDocuments.Where(tnd => tnd.TreeNodeId == Id).ToArray());

            lTreeNodeDocs.ForEach(tnd => tnd.Delete(db));
            int thumbnailId = this.ThumbnailId;

            // remove
            while (TreeNodeGroupShare.Count() > 0)
            {
                TreeNodeGroupShare tnGpShare = TreeNodeGroupShare.First();
                db.TreeNodeGroupShares.Remove(tnGpShare);
            }
            db.SaveChanges();
            // actually remove node
            db.TreeNodes.Remove(this);
            db.SaveChanges();
            // delete thubnail
            Thumbnail.DeleteIfNotRefered(db, thumbnailId);
        }
Exemple #2
0
 public bool IsShared(Group gp)
 {
     if (Group == gp)
     {
         return(true);
     }
     if (TreeNodeGroupShare.Count(tngs => tngs.TreeNodeId == Id && tngs.GroupId == gp.Id) > 0)
     {
         return(true);
     }
     return(false);
 }