BExIS.Web.Shell.Controllers.TestController.removeContentDescriptor C# (CSharp) Method

removeContentDescriptor() private method

private removeContentDescriptor ( ) : void
return void
        private void removeContentDescriptor()
        {
            DatasetManager dm = new DatasetManager();
            Dataset dataset = dm.GetDataset(1);
            // check if the dataset is in the checked-in status
            DatasetVersion dsVersion = dm.GetDatasetLatestVersion(dataset);
            if(dsVersion.ContentDescriptors.Count(p => p.Name.Equals("generated")) > 0)
            {
                dm.CheckOutDataset(1, "admin");
                dsVersion = dm.GetDatasetWorkingCopy(1);
                //dm.EditDatasetVersion(dsVersion, null, null, null, null);
                // The descriptor to be deleted must be object equal to the one in the list. The following command does the job.
                // The condition can be different, but the item should be taken from the list, and any other instance must be released, by setting them to NULL.
                var cd = dsVersion.ContentDescriptors.FirstOrDefault(p => p.Name.Equals("generated"));
                dm.DeleteContentDescriptor(cd);
                dm.CheckInDataset(1, "removed content descriptor:" + cd.Name, "admin");
            }
        }