Created
March 12, 2014 17:10
SF_10.1, SF_10.2, SF_11.0, SF_11.1, SF_11.2, SF_12.0, SF_12.1, SF_12.2, SF_13.0, SF_13.1, SF_13.2, SF_13.3, SF_14.0, SF_14.1, SF_14.2, SF_14.3 - https://docs.sitefinity.com/for-developers-create-image-libraries
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Linq; | |
using System.Text.RegularExpressions; | |
using Telerik.Sitefinity.Libraries.Model; | |
using Telerik.Sitefinity.Modules.Libraries; | |
namespace Telerik.Sitefinity.Documentation.CodeSnippets.DevGuide.SitefinityEssentials.Modules.MediaModules.Images.Albums | |
{ | |
public partial class AlbumsSnippets | |
{ | |
private void CreateAlbumNativeAPI(Guid albumId, string albumTitle) | |
{ | |
LibrariesManager librariesManager = LibrariesManager.GetManager(); | |
Album album = librariesManager.GetAlbums().Where(a => a.Id == albumId).FirstOrDefault(); | |
if (album == null) | |
{ | |
//Create the album. | |
album = librariesManager.CreateAlbum(albumId); | |
//Set the properties of the album. | |
album.Title = albumTitle; | |
album.DateCreated = DateTime.UtcNow; | |
album.LastModified = DateTime.UtcNow; | |
album.UrlName = Regex.Replace(albumTitle.ToLower(), @"[^\w\-\!\$\'\(\)\=\@\d_]+", "-"); | |
//Recompiles and validates the url of the album. | |
librariesManager.RecompileAndValidateUrls(album); | |
//Save the changes. | |
librariesManager.SaveChanges(); | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment