public void UpdateProject(ProjectViewModel m) { using (new TransactionScope(TransactionScopeOption.Suppress)) { var now = DateTime.UtcNow; var d = new ProjectsDataContext(); var p = new Project(); p.ProjectName = (m.ProjectName == "null") ? null : m.ProjectName; p.Comment = (m.Comment == "null") ? null : m.Comment; p.ProjectID = Guid.NewGuid(); p.VersionOwnerContactID = m.Creator; p.VersionUpdated = now; p.VersionUpdatedBy = m.User; d.Projects.InsertOnSubmit(p); var n = new ProjectPlan(); n.ProjectPlanID = Guid.NewGuid(); n.ProjectID = p.ProjectID; n.ProjectPlanName = "Resource Modelling"; n.ResponsibleContactID = m.Creator; n.VersionOwnerContactID = m.User; n.VersionUpdated = now; n.VersionUpdatedBy = m.User; d.ProjectPlans.InsertOnSubmit(n); var t = new ProjectPlanTask(); t.ProjectPlanTaskID = Guid.NewGuid(); t.ProjectPlanID = n.ProjectPlanID; t.ProjectTaskName = m.StageName; t.VersionOwnerContactID = m.Creator; t.VersionUpdated = now; t.VersionUpdatedBy = m.User; d.ProjectPlanTasks.InsertOnSubmit(t); var tr = new ProjectPlanTask(); tr.ProjectPlanTaskID = Guid.NewGuid(); tr.ProjectPlanID = n.ProjectPlanID; tr.ProjectTaskName = "Review"; tr.VersionOwnerContactID = m.Reviewer; tr.VersionUpdated = now.AddSeconds(-1); //This is not the current task tr.VersionUpdatedBy = m.User; d.ProjectPlanTasks.InsertOnSubmit(tr); var tc = new ProjectPlanTask(); tc.ProjectPlanTaskID = Guid.NewGuid(); tc.ProjectPlanID = n.ProjectPlanID; tc.ProjectTaskName = "Complete"; tc.VersionOwnerContactID = m.User; tc.VersionUpdated = now.AddSeconds(-1); //This is not the current task tc.VersionUpdatedBy = m.User; d.ProjectPlanTasks.InsertOnSubmit(tr); d.SubmitChanges(); } }
partial void DeleteProjectPlanTask(ProjectPlanTask instance);
partial void UpdateProjectPlanTask(ProjectPlanTask instance);
partial void InsertProjectPlanTask(ProjectPlanTask instance);
private void detach_ProjectPlanTasks(ProjectPlanTask entity) { this.SendPropertyChanging(); entity.X_ProjectPlanTask1 = null; }
private void attach_ProjectPlanTasks(ProjectPlanTask entity) { this.SendPropertyChanging(); entity.ProjectPlan = this; }