} // AddProjectQuestion public IList<Project> UpdateProjectQuestion(Guid orgId, Guid projId, ProjectQuestionData pqd) { var pod = POD(orgId); if (pod.Projects == null) throw new Exception("Organisation has no projects"); var currentProject = pod.Projects.Find(p => p.Id == projId); if (currentProject == null) throw new Exception("Project does not belong to the organisation"); var question = currentProject.Questions.Where(q => q.Id == pqd.Id).Single(); question.Question = pqd.Question; question.Answers = pqd.Answers; Commit(currentProject); return FetchProjects(orgId); } // AddProjectQuestion
} // DeleteProjects public IList<Project> AddProjectQuestion(Guid orgId, Guid projId, ProjectQuestionData pqd) { var pod = POD(orgId); if (pod.Projects == null) throw new Exception("Organisation has no projects"); var currentProject = pod.Projects.Find(p => p.Id == projId); if (currentProject == null) throw new Exception("Project does not belong to the organisation"); if (currentProject.Questions == null) currentProject.Questions = new List<ProjectQuestionData>(); pqd.Id = Guid.NewGuid(); currentProject.Questions.Add(pqd); Commit(currentProject); return FetchProjects(orgId); } // AddProjectQuestion