コード例 #1
0
        public static Question LoadById(Guid id)
        {
            try
            {
                using (SurveyEntities dc = new SurveyEntities())
                {
                    tblQuestion row      = dc.tblQuestions.FirstOrDefault(q => q.Id == id);
                    Question    question = new Question {
                        Id = row.Id, Text = row.Question
                    };
                    List <Activation> activations = ActivationManager.Load();
                    question.Activator = activations.FirstOrDefault(a => a.QuestionId == question.Id);

                    if (row != null)
                    {
                        question.Answers = AnswerManager.Load(row.Id);
                    }
                    return(question);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
コード例 #2
0
 public static List <Question> Load()
 {
     try
     {
         List <Question> questions = new List <Question>();
         using (SurveyEntities dc = new SurveyEntities())
         {
             dc.tblQuestions
             .ToList()
             .ForEach(q => questions.Add(new Question
             {
                 Id        = q.Id,
                 Text      = q.Question,
                 Answers   = AnswerManager.Load(q.Id),
                 Activator = ActivationManager.GetActivation(q.Id)
             }));
         }
         return(questions);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }