Kentico CMS 7.0 Developer's Guide

Managing projects

Managing projects

Previous topic Next topic Mail us feedback on this topic!  

Managing projects

Previous topic Next topic JavaScript is required for the print function Mail us feedback on this topic!  

Arrow


API examples for newer versions


Please visit the latest API Examples documentation to view API examples for newer versions of Kentico.



The following example creates a project.

 

private void CreateProject()
{

  ProjectStatusInfo status = ProjectStatusInfoProvider.GetProjectStatusInfo("NotStarted");

 
    if (status != null)
    {
        int currentUserID = CMSContext.CurrentUser.UserID;
 
        // Create new project object
        ProjectInfo newProject = new ProjectInfo();
 
        // 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.

 

private bool 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);
 
        return true;
    }
 
    return false;
}

 

The following example gets and bulk updates projects.

 

private bool 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 = new ProjectInfo(projectDr);

 
          // Update the properties
           modifyProject.ProjectDisplayName = modifyProject.ProjectDisplayName.ToUpper();

 
            // Save the changes
            ProjectInfoProvider.SetProjectInfo(modifyProject);
        }
 
        return true;
    }
 
    return false;
}

 

The following example deletes a project.

 

private bool DeleteProject()
{

  // Get the project
  ProjectInfo deleteProject = ProjectInfoProvider.GetProjectInfo("MyNewProject", CMSContext.CurrentSiteID, 0);

 
    // Delete the project
    ProjectInfoProvider.DeleteProjectInfo(deleteProject);
 
    return (deleteProject != null);
}