ProjectStatusInfo status = ProjectStatusInfoProvider.GetProjectStatusInfo("NotStarted");
if (status != null) { int currentUserID = CMSContext.CurrentUser.UserID; // Create new project object ProjectInfo newProject = newProjectInfo(); // Set the properties newProject.ProjectDisplayName = "My new project"; newProject.ProjectName = "MyNewProject"; newProject.ProjectStatusID = status.StatusID; newProject.ProjectSiteID = CMSContext.CurrentSiteID; newProject.ProjectOwner = currentUserID; newProject.ProjectCreatedByID = currentUserID; // Save the project ProjectInfoProvider.SetProjectInfo(newProject); } }
The following example gets and updates a project.
privatebool GetAndUpdateProject() {
// Get the project ProjectInfo updateProject = ProjectInfoProvider.GetProjectInfo("MyNewProject", CMSContext.CurrentSiteID, 0);
if (updateProject != null) {
// Update the properties updateProject.ProjectDisplayName = updateProject.ProjectDisplayName.ToLower();
// Save the changes ProjectInfoProvider.SetProjectInfo(updateProject); returntrue; } returnfalse; }
The following example gets and bulk updates projects.
privatebool GetAndBulkUpdateProjects() { // Prepare the parameters string where = "ProjectName LIKE N'MyNewProject%'"; string orderBy = ""; int topN = 0; string columns = "";
// Get the data DataSet projects = ProjectInfoProvider.GetProjects(where, orderBy, topN, columns);
if (!DataHelper.DataSourceIsEmpty(projects)) { // Loop through the individual items foreach (DataRow projectDr in projects.Tables[0].Rows) { // Create object from DataRow ProjectInfo modifyProject = newProjectInfo(projectDr);
// Update the properties modifyProject.ProjectDisplayName = modifyProject.ProjectDisplayName.ToUpper();
// Save the changes ProjectInfoProvider.SetProjectInfo(modifyProject); } returntrue; } returnfalse; }
The following example deletes a project.
privatebool DeleteProject() {
// Get the project ProjectInfo deleteProject = ProjectInfoProvider.GetProjectInfo("MyNewProject", CMSContext.CurrentSiteID, 0);
// Delete the project ProjectInfoProvider.DeleteProjectInfo(deleteProject); return (deleteProject != null); }