Dynamically Create Image Album - Front- & Back-End Development - Front- & Back-End Development - Progress Community
 Front- & Back-End Development

Dynamically Create Image Album

  • Dynamically Create Image Album
  • I've been trying to dynamically create a image album and I've used the following sample code from the API documentaiton.  The problem is that this code returns an empty GUID and the Album doesn't appear in SiteFinity.  Is this a bug or am I missing something obvious?

    (I'm using SiteFinity 4.0 SP1)

    public static Guid CreateAlbum(string title, string urlName, string description)
        Guid newAlbumId = Guid.Empty;
        App.WorkWith().Album()
            .CreateNew()
            .Do(a =>
                
                    a.Title = title;
                    a.Description = description;
                    a.UrlName = urlName;
                    newAlbumId = a.Id;
                )
            .SaveChanges();
        return newAlbumId;

    Thanks for your assistance.
  • Hi Scott,

    Try using this code

    private Album CreateAlbum(urlName)
     
         var manager = LibrariesManager.GetManager();   
         var album = manager.GetAlbums().ToList().Where(a => a.UrlName == "somename").FirstOrDefault();
         if (album == null)
         
             App.WorkWith().Album().CreateNew().Do(
                 a =>
                 
                     a.Title = "Album for blog " + blog.Title;
                     a.Description = "my description";
                    var id = a.Id;
                 
             ).Get(out album).SaveChanges();
         
         return album;
     

    I am not able to replicate the issue you reported. The Id is returned by the Content object

    Regards,
    Ivan Dimitrov
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items