if ((project != null) && (status != null) && (priority != null)) { // Create new project task object ProjectTaskInfo newTask = newProjectTaskInfo(); int currentUserID = CMSContext.CurrentUser.UserID; // Set the properties newTask.ProjectTaskDisplayName = "My new task"; newTask.ProjectTaskCreatedByID = currentUserID; newTask.ProjectTaskOwnerID = currentUserID; newTask.ProjectTaskAssignedToUserID = currentUserID; newTask.ProjectTaskStatusID = status.TaskStatusID; newTask.ProjectTaskPriorityID = priority.TaskPriorityID; newTask.ProjectTaskProjectID = project.ProjectID; // Save the project task ProjectTaskInfoProvider.SetProjectTaskInfo(newTask); returntrue; } returnfalse; }
The following example gets and updates a task.
privatebool GetAndUpdateProjectTask() { // Prepare the parameters string where = "ProjectTaskDisplayName LIKE N'My new task%'"; string orderBy = ""; int topN = 0; string columns = "";
// Get the data DataSet tasks = ProjectTaskInfoProvider.GetProjectTasks(where, orderBy, topN, columns);
if (!DataHelper.DataSourceIsEmpty(tasks)) { // Get the project task ProjectTaskInfo updateTask = newProjectTaskInfo(tasks.Tables[0].Rows[0]); if (updateTask != null) {
// Update the properties updateTask.ProjectTaskDisplayName = updateTask.ProjectTaskDisplayName.ToLower();
// Save the changes ProjectTaskInfoProvider.SetProjectTaskInfo(updateTask); returntrue; } } returnfalse; }
The following example gets and bulk updates tasks.
privatebool GetAndBulkUpdateProjectTasks() { // Prepare the parameters string where = "ProjectTaskDisplayName LIKE N'My new task%'"; string orderBy = ""; int topN = 0; string columns = "";
// Get the data DataSet tasks = ProjectTaskInfoProvider.GetProjectTasks(where, orderBy, topN, columns);
if (!DataHelper.DataSourceIsEmpty(tasks)) { // Loop through the individual items foreach (DataRow taskDr in tasks.Tables[0].Rows) { // Create object from DataRow ProjectTaskInfo modifyTask = newProjectTaskInfo(taskDr);
// Update the properties modifyTask.ProjectTaskDisplayName = modifyTask.ProjectTaskDisplayName.ToUpper();
// Save the changes ProjectTaskInfoProvider.SetProjectTaskInfo(modifyTask); } returntrue; } returnfalse; }
The following example deletes a task.
privatebool DeleteProjectTask() { // Prepare the parameters string where = "ProjectTaskDisplayName LIKE N'My new task%'"; string orderBy = ""; int topN = 0; string columns = "";
// Get the data DataSet tasks = ProjectTaskInfoProvider.GetProjectTasks(where, orderBy, topN, columns);
if (!DataHelper.DataSourceIsEmpty(tasks)) {
// Get the project task ProjectTaskInfo deleteTask = newProjectTaskInfo(tasks.Tables[0].Rows[0]);