private static void UpdateProjectAndManager(int todoId, int projectId, int managerId) { int oldProjectId = DBToDo.GetProject(todoId); int oldManagerId = DBToDo.GetManager(todoId); if (projectId == 0) // leave old project { projectId = oldProjectId; } if (managerId == 0) // Leave old manager { managerId = oldManagerId; } if (projectId != oldProjectId && projectId > 0 && !ToDo.CanCreate(projectId)) { throw new AccessDeniedException(); } if (projectId != oldProjectId || managerId != oldManagerId) { using (DbTransaction tran = DbTransaction.Begin()) { DBToDo.UpdateProjectAndManager(todoId, projectId, managerId); // OZ: User Role Addon if (managerId != oldManagerId) { UserRoleHelper.DeleteTodoManagerRole(todoId, oldManagerId); UserRoleHelper.AddTodoManagerRole(todoId, managerId); } if (projectId != oldProjectId) { ForeignContainerKey.Delete(UserRoleHelper.CreateTodoContainerKey(todoId), UserRoleHelper.CreateProjectContainerKey(oldProjectId)); if (projectId > 0) { ForeignContainerKey.Add(UserRoleHelper.CreateTodoContainerKey(todoId), UserRoleHelper.CreateProjectContainerKey(projectId)); } } // end OZ if (projectId != oldProjectId) { if (projectId > 0) { SystemEvents.AddSystemEvents(SystemEventTypes.Project_Updated_TodoList_TodoAdded, projectId, todoId); } else { SystemEvents.AddSystemEvents(SystemEventTypes.Project_Updated_TodoList_TodoDeleted, oldProjectId, todoId); } // O.R. [2008-07-30] if (oldProjectId > 0) { TimeTracking.RecalculateProjectTaskTime(oldProjectId); } if (projectId > 0) { TimeTracking.RecalculateProjectTaskTime(projectId); } } if (managerId != oldManagerId) { SystemEvents.AddSystemEvents(SystemEventTypes.Todo_Updated_Manager_ManagerDeleted, todoId, oldManagerId); SystemEvents.AddSystemEvents(SystemEventTypes.Todo_Updated_Manager_ManagerAdded, todoId, managerId); } tran.Commit(); } } }