Dynamically Create Image Album

Posted by Community Admin on 05-Aug-2018 23:04

Dynamically Create Image Album

All Replies

Posted by Community Admin on 29-Mar-2011 00:00

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.

Posted by Community Admin on 04-Apr-2011 00:00

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

This thread is closed