How to return a specific downloadable product/document. - Front- & Back-End Development - Front- & Back-End Development - Progress Community
 Front- & Back-End Development

How to return a specific downloadable product/document.

  • How to return a specific downloadable product/document.
  • Does anyone know how to return a link or a stream to a downloadable product.

    I found this code in the documentation:

    public static DocumentLibrary GetDownloadableGoodsLibrary()  
     string providerName = "SystemLibrariesProvider";   
    Guid downloadableGoodsId = new Guid("e5915e51-707e-4232-9830-68f2800067f8");    
    LibrariesManager librariesManager = LibrariesManager.GetManager(providerName);   
     DocumentLibrary downloadableGoods = librariesManager.GetDocumentLibraries().Where(d => d.Id == downloadableGoodsId).SingleOrDefault();    
    return downloadableGoods;

    Can someone fill me in on how to get a specific downloadable document?

    Thanks
  • Hi Keefe,

     The downloadable goods library is just a "system" library. It can be queried, along with its contents, like you would any other public library. The documentation you have is just how to get the entire library. So once you have it you can get documents a few different ways.

    Here's an example of a few ways.

    public string providerName = "SystemLibrariesProvider";
     
            public  DocumentLibrary GetDownloadableGoodsLibrary()
            
                Guid downloadableGoodsId = new Guid("e5915e51-707e-4232-9830-68f2800067f8");
     
                LibrariesManager librariesManager = LibrariesManager.GetManager(providerName);
     
                DocumentLibrary downloadableGoods = librariesManager.GetDocumentLibraries().Where(d => d.Id == downloadableGoodsId).SingleOrDefault();
     
                return downloadableGoods;
            
     
            public IQueryable<Document> GetDownloadableGoodsByLibrary(DocumentLibrary docLib)
            
                return docLib.Documents();
            
     
            public Document GetDownloadableGoodByTitle(string title)
            
                var lm = LibrariesManager.GetManager(providerName);
                return lm.GetDocuments().Where(d => d.Title == title).FirstOrDefault();
            
     
            public List<Document> GetDownloadableGoodsByProduct(Product product)
            
                var returnList = new List<Document>();
                var lm = LibrariesManager.GetManager();
                foreach (var file in product.Files)
                
                    var doc = lm.GetDocuments().Where(d => d.Title == file.Title).FirstOrDefault();
                    returnList.Add(doc);
                
                return returnList;
            

    I hope this helps.

    Regards,
    Patrick Dunn
    Telerik
    Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items