public AllData() { using (informatikexamenEntities db = new informatikexamenEntities()) { RQRList = db.RQR.ToList(); RQTList = db.RQT.ToList(); RList = db.Response.ToList(); QRList = db.QuestionResponse.ToList(); QList = db.Question.ToList(); } }
public QuestionInfo(Question q) { Q = q; R = new List <Response>(); using (informatikexamenEntities db = new informatikexamenEntities()) { QR = db.QuestionResponse.Where(x => x.QuestionID == Q.Id).ToList(); foreach (QuestionResponse qr in QR) { R.Add(db.Response.Where(x => x.Id == qr.ResponseID).FirstOrDefault()); } } }
//public AllData(Respondent r) //{ // using (informatikexamenEntities db = new informatikexamenEntities()) // { // List<QuestionResponse> tempList = db.QuestionResponse.ToList(); // RList = db.Response.ToList(); // QRList = new List<QuestionResponse>(); // List<Question> ql = db.Question.ToList(); // RQRList = db.RQR.Where(x => x.RespondentID == r.Id).ToList(); // RQTList = db.RQT.Where(x => x.RespondentID == r.Id).ToList(); // foreach (RQR rqr in RQRList) // { // foreach (QuestionResponse qr in tempList) // { // if (qr.Id == rqr.QuestionResponseID) // { // QRList.Add(qr); // } // } // } // } //} public string GetAnswer(int qID) { Response response = new Response(); response.ResponseText = "Saknas"; using (informatikexamenEntities db = new informatikexamenEntities()) { foreach (QuestionResponse qr in QRList) { if (qr.QuestionID == qID) { response = RList.Where(x => x.Id == qr.ResponseID).FirstOrDefault(); } } } return(response.ResponseText); }