Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Jayesh 7 posts 27 karma points
    May 16, 2012 @ 06:37
    Jayesh
    0

    trying to delete related Document?

    I have a related multilinugal site in umbraco 4.7.2 trying to delete and unpublish the documents using their relation in application base .cs file : 

    My code is :

     

        var allDocId = SqlHelper.ExecuteScalar<Object>("Select nodeId from cmsDocument");

                Document currDoc = new Document(sender.Id);

                Relation[] relations = Relation.GetRelations(sender.Id);

                //Relation[] re = sender.Relations;

                foreach (var cDocId in allDocId.ToString())

                {

                   foreach (var r in relations)

                   {

                       int cId = int.Parse(cDocId.ToString());

                       if( cId == r.Child.Id)

                        {

                            Document delDoc = new Document(r.Child.Id);

                            if (delDoc.Published)

                             {

    delDoc.UnPublish();

    }

                            delDoc.delete();

                        }

                    }

                }

     

     

    I dont know why , but related document does not get deleted. can anyone help me for this problem.

     

    thanks in advance.

Please Sign in or register to post replies

Write your reply to:

Draft