Beispiel #1
0
 public void Update()
 {
     questions = new List <string>();
     try
     {
         using (var db = new EntityDM.MillionareDBEntities3())
         {
             answersList = db.Answers.ToList();
             List <EntityDM.Questions> questionsList = db.Questions.ToList();
             foreach (var item in questionsList)
             {
                 questions.Add(item.Question);
             }
         }
     }
     catch { throw; }
 }
Beispiel #2
0
 public void delete(string qeuestion_)
 {
     try
     {
         using (var db = new EntityDM.MillionareDBEntities3())
         {
             IQueryable <EntityDM.Questions> question = db.Questions;
             IQueryable <EntityDM.Answers>   answer   = db.Answers;
             var q = question.Where(x => x.Question.Equals(qeuestion_)).ToList().First();
             var a = answer.Where(x => x.Questions_FK == q.Id).ToList().First();
             db.Answers.Remove(a);
             db.Questions.Remove(q);
             db.SaveChanges();
             Update();
         }
     }
     catch
     { throw; }
 }
 public void Edit(QuestionAnswersStruct qa)
 {
     try
     {
         using (var db = new EntityDM.MillionareDBEntities3())
         {
             IQueryable <EntityDM.Questions> q = db.Questions;
             IQueryable <EntityDM.Answers>   a = db.Answers;
             var question = q.Where(x => x.Question.Equals(qa.question_old)).ToList().First();
             var answer   = a.Where(x => x.Questions_FK == question.Id).ToList().First();
             answer.Answer_A   = qa.answerA;
             answer.Answer_B   = qa.answerB;
             answer.Answer_C   = qa.answerC;
             answer.Answer_D   = qa.answerD;
             question.Question = qa.question_new;
             db.SaveChanges();
             Update();
         }
     }
     catch
     { throw; }
 }