Created
November 21, 2013 12:57
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-document-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.Collections.Generic; | |
using System.Linq; | |
using System.Text; | |
using System.Text.RegularExpressions; | |
using System.Threading.Tasks; | |
namespace Telerik.Sitefinity.Documentation.CodeSnippets.DevGuide.SitefinityEssentials.Modules.MediaModules.DocumentsAndFiles.ManagingLibraries | |
{ | |
public partial class LibrariesSnippets | |
{ | |
private void CreateDocumentLibraryFluentAPI(Guid documentLibraryId, string documentLibraryTitle) | |
{ | |
//Check whether a library with the same ID already exists. | |
var count = 0; | |
App.WorkWith().DocumentLibraries().Where(b => b.Id == documentLibraryId).Count(out count); | |
if (count == 0) | |
{ | |
//Create the library. | |
App.WorkWith().DocumentLibrary().CreateNew(documentLibraryId) | |
//Set the properties of the library. | |
.Do(b => | |
{ | |
b.Title = documentLibraryTitle; | |
b.DateCreated = DateTime.UtcNow; | |
b.LastModified = DateTime.UtcNow; | |
b.UrlName = Regex.Replace(documentLibraryTitle.ToLower(), @"[^\w\-\!\$\'\(\)\=\@\d_]+", "-"); | |
}) | |
//Save the changes. | |
.SaveChanges(); | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment