Last active
August 29, 2015 14:22
-
-
Save davidknipe/4f53125af30a1805c868 to your computer and use it in GitHub Desktop.
Create an EPiServer Project programmatically
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
/// <summary> | |
/// Create a project programmatically | |
/// </summary> | |
/// <param name="projectName">The name of the project, e.g. "Weekly article updates"</param> | |
/// <param name="userName">The username of the person creating the project</param> | |
/// <returns>The newly created project, null if a project with that name already exists</returns> | |
public Project CreateNewProject(string projectName, string userName) | |
{ | |
var repo = ServiceLocator.Current.GetInstance<ProjectRepository>(); | |
var newProject = new Project(); | |
if (repo.List().Any(x => x.Name == projectName) == false) | |
{ | |
newProject.Name = projectName; | |
newProject.CreatedBy = userName; | |
repo.Save(newProject); | |
return newProject; | |
} | |
return null; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment