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;
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;