Component Page /UserTest.cs (C#)
1: using System;  
2: using System.Collections.Generic;  
3: using System.Linq;  
4: using Microsoft.ApplicationBlocks.Data;  
5: using System.Data.SqlClient;  
6: using System.Data;  
7: using System.Xml.Linq;  
8:   
9: namespace QuizNetOnline.Logic  
10: {  
11:     [Serializable]  
12:     public class UserTest  
13:     {  
14:         public int ID { get; set; }  
15:         public string UserName { get; set; }  
16:         public int QuestionPos { get; set; }  
17:         public Topic Topic { get; set; }  
18:         public int Correct { get; set; }  
19:         public int Incorrect { get; set; }  
20:         public string QuizType { get; set; }  
21:         public string TagType { get; set; }  
22:   
23:         public List<Question> ArrayListCorrect { get; set; }  
24:         public List<Question> ArrayListIncorrect { get; set; }  
25:   
26:         public void SaveQuiz()  
27:         {  
28:             if (Topic.TopicCode.ToLower() != "movie" && Topic.TopicCode.ToLower() != "new")  
29:             {  
30:                 ISqlWrapper isqlWrapper = new SqlWrapper();  
31:   
32:                 var xmlCorrect = new XElement("Questions");  
33:                 var xmlIncorrect = new XElement("Questions");  
34:   
35:                 if (ArrayListCorrect != null)  
36:                 {  
37:                     //Remove duplicates  
38:                     ArrayListCorrect = ArrayListCorrect.Distinct().ToList();  
39:                     xmlCorrect = new XElement("Questions",  
40:                                               from correct in ArrayListCorrect  
41:                                               select new XElement("id", correct.QuestionId));  
42:                 }  
43:                 if (ArrayListIncorrect != null)  
44:                 {  
45:                     //Remove duplicates  
46:                     ArrayListIncorrect = ArrayListIncorrect.Distinct().ToList();  
47:                     var arrayListIncorrect=new List<Question>();  
48:   
49:                     //Make sure a duplicate question doesnt exist in ArrayListCorrect  
50:                     foreach (var question in ArrayListIncorrect)  
51:                     {  
52:                         if(ArrayListCorrect!=null && !ArrayListCorrect.Exists(element => element.QuestionId==question.QuestionId))  
53:                         {  
54:                             arrayListIncorrect.Add(question);  
55:                         }  
56:                     }  
57:                     xmlIncorrect = new XElement("Questions",  
58:                                                 from correct in arrayListIncorrect  
59:                                                 select new XElement("id", correct.QuestionId));  
60:                 }  
61:   
62:                 const string sproc = "UpdateUserQuestionSave";  
63:                 var parameters = new SqlParameter[10];  
64:                 parameters[0] = new SqlParameter("@QuestionPos", QuestionPos);  
65:                 parameters[1] = new SqlParameter("@UserName", UserName);  
66:                 parameters[2] = new SqlParameter("@TopicCode", Topic.TopicCode);  
67:                 parameters[3] = new SqlParameter("@Correct", Correct);  
68:                 parameters[4] = new SqlParameter("@Incorrect", Incorrect);  
69:                 parameters[5] = new SqlParameter("@CorrectQuestion", xmlCorrect.ToString());  
70:                 parameters[6] = new SqlParameter("@IncorrectQuestion", xmlIncorrect.ToString());  
71:                 parameters[7] = new SqlParameter("@QuizType", QuizType);  
72:                 parameters[8] = new SqlParameter("@TagType", TagType);  
73:                 parameters[9] = new SqlParameter("@UserQuestionSaveID", 0);  
74:                 parameters[9].Direction = ParameterDirection.Output;  
75:   
76:   
77:                 try  
78:                 {  
79:                       
80:                     string connStr = isqlWrapper.GetConnectionString();  
81:                     SqlHelper.ExecuteNonQuery(connStr, CommandType.StoredProcedure, sproc, parameters);  
82:                     ID = Convert.ToInt32(parameters[9].Value);  
83:                 }  
84:                 catch (Exception ex)  
85:                 {  
86:                     ErrorLog errorLog = new ErrorLog();  
87:                     errorLog.LogException("UserTest.SaveQuiz - xmlCorrect:" + xmlCorrect + "|xmlIncorrect:" + xmlIncorrect, ex, isqlWrapper);  
88:                     throw;  
89:                 }  
90:             }  
91:         }  
92:   
93:         public List<UserTest> LoadQuizzes(bool includePastQuestionsCorrectIncorrect,string userName,string quizType,string tagType, ISqlWrapper isqlWrapper)  
94:         {  
95:             UserName = userName;  
96:             Topic = null;  
97:             QuizType = quizType;  
98:             TagType = tagType;  
99:   
100:             return LoadQuiz(includePastQuestionsCorrectIncorrect,isqlWrapper);  
101:         }  
102:   
103:         public List<UserTest> LoadQuizzes(bool includePastQuestionsCorrectIncorrect, string userName, string topicCode, ISqlWrapper isqlWrapper)  
104:         {  
105:             UserName = userName;  
106:             Topic = new Topic(topicCode);  
107:   
108:             return LoadQuiz(includePastQuestionsCorrectIncorrect, isqlWrapper);  
109:         }  
110:   
111:         public bool DeleteUserTest(string userName,string topicCode, string quizType, string tagType, ISqlWrapper isqlWrapper)  
112:         {  
113:             UserName = userName;  
114:             Topic = null;  
115:             QuizType = quizType;  
116:             TagType = tagType;  
117:   
118:             const string sproc = "DeleteUserQuestionByUser";  
119:             var parameters = new SqlParameter[4];  
120:   
121:             parameters[0] = new SqlParameter("@UserName", UserName);  
122:             parameters[1] = new SqlParameter("@TopicCode", topicCode);  
123:             parameters[2] = new SqlParameter("@QuizType", QuizType);  
124:             parameters[3] = new SqlParameter("@TagType", TagType);  
125:   
126:   
127:             try  
128:             {  
129:                 string connStr = isqlWrapper.GetConnectionString();  
130:   
131:                 isqlWrapper.ExecuteNonQuery(connStr, CommandType.StoredProcedure, sproc, parameters);  
132:   
133:                 return true;  
134:             }  
135:             catch (Exception ex)  
136:             {  
137:                 ErrorLog errorLog = new ErrorLog();  
138:                 errorLog.LogException("UserTest.DeleteUserTest", ex, isqlWrapper);  
139:                 throw;  
140:             }  
141:         }  
142:   
143:   
144:         public void LoadQuiz(bool includePastQuestionsCorrectIncorrect,string userName, Topic topic,string quizType, string tagType,ISqlWrapper isqlWrapper)  
145:         {  
146:             UserName = userName;  
147:             Topic = topic;  
148:             QuizType = quizType;  
149:             TagType = tagType;  
150:   
151: There is a limit of 150 source code lines in the evaluation version
152: There is a limit of 150 source code lines in the evaluation version
153: There is a limit of 150 source code lines in the evaluation version
154: There is a limit of 150 source code lines in the evaluation version
155: There is a limit of 150 source code lines in the evaluation version
156: There is a limit of 150 source code lines in the evaluation version
157: There is a limit of 150 source code lines in the evaluation version
158: There is a limit of 150 source code lines in the evaluation version
159: There is a limit of 150 source code lines in the evaluation version
160: There is a limit of 150 source code lines in the evaluation version
161: There is a limit of 150 source code lines in the evaluation version
162: There is a limit of 150 source code lines in the evaluation version
163: There is a limit of 150 source code lines in the evaluation version
164: There is a limit of 150 source code lines in the evaluation version
165: There is a limit of 150 source code lines in the evaluation version
166: There is a limit of 150 source code lines in the evaluation version
167: There is a limit of 150 source code lines in the evaluation version
168: There is a limit of 150 source code lines in the evaluation version
169: There is a limit of 150 source code lines in the evaluation version
170: There is a limit of 150 source code lines in the evaluation version
171: There is a limit of 150 source code lines in the evaluation version
172: There is a limit of 150 source code lines in the evaluation version
173: There is a limit of 150 source code lines in the evaluation version
174: There is a limit of 150 source code lines in the evaluation version
175: There is a limit of 150 source code lines in the evaluation version
176: There is a limit of 150 source code lines in the evaluation version
177: There is a limit of 150 source code lines in the evaluation version
178: There is a limit of 150 source code lines in the evaluation version
179: There is a limit of 150 source code lines in the evaluation version
180: There is a limit of 150 source code lines in the evaluation version
181: There is a limit of 150 source code lines in the evaluation version
182: There is a limit of 150 source code lines in the evaluation version
183: There is a limit of 150 source code lines in the evaluation version
184: There is a limit of 150 source code lines in the evaluation version
185: There is a limit of 150 source code lines in the evaluation version
186: There is a limit of 150 source code lines in the evaluation version
187: There is a limit of 150 source code lines in the evaluation version
188: There is a limit of 150 source code lines in the evaluation version
189: There is a limit of 150 source code lines in the evaluation version
190: There is a limit of 150 source code lines in the evaluation version
191: There is a limit of 150 source code lines in the evaluation version
192: There is a limit of 150 source code lines in the evaluation version
193: There is a limit of 150 source code lines in the evaluation version
194: There is a limit of 150 source code lines in the evaluation version
195: There is a limit of 150 source code lines in the evaluation version
196: There is a limit of 150 source code lines in the evaluation version
197: There is a limit of 150 source code lines in the evaluation version
198: There is a limit of 150 source code lines in the evaluation version
199: There is a limit of 150 source code lines in the evaluation version
200: There is a limit of 150 source code lines in the evaluation version
201: There is a limit of 150 source code lines in the evaluation version
202: There is a limit of 150 source code lines in the evaluation version
203: There is a limit of 150 source code lines in the evaluation version
204: There is a limit of 150 source code lines in the evaluation version
205: There is a limit of 150 source code lines in the evaluation version
206: There is a limit of 150 source code lines in the evaluation version
207: There is a limit of 150 source code lines in the evaluation version
208: There is a limit of 150 source code lines in the evaluation version
209: There is a limit of 150 source code lines in the evaluation version
210: There is a limit of 150 source code lines in the evaluation version
211: There is a limit of 150 source code lines in the evaluation version
212: There is a limit of 150 source code lines in the evaluation version
213: There is a limit of 150 source code lines in the evaluation version
214: There is a limit of 150 source code lines in the evaluation version
215: There is a limit of 150 source code lines in the evaluation version
216: There is a limit of 150 source code lines in the evaluation version
217: There is a limit of 150 source code lines in the evaluation version
218: There is a limit of 150 source code lines in the evaluation version
219: There is a limit of 150 source code lines in the evaluation version
220: There is a limit of 150 source code lines in the evaluation version
221: There is a limit of 150 source code lines in the evaluation version
222: There is a limit of 150 source code lines in the evaluation version
223: There is a limit of 150 source code lines in the evaluation version
224: There is a limit of 150 source code lines in the evaluation version
225: There is a limit of 150 source code lines in the evaluation version
226: There is a limit of 150 source code lines in the evaluation version
227: There is a limit of 150 source code lines in the evaluation version
228: There is a limit of 150 source code lines in the evaluation version
229: There is a limit of 150 source code lines in the evaluation version
230: There is a limit of 150 source code lines in the evaluation version
231: There is a limit of 150 source code lines in the evaluation version
232: There is a limit of 150 source code lines in the evaluation version
233: There is a limit of 150 source code lines in the evaluation version
234: There is a limit of 150 source code lines in the evaluation version
235: There is a limit of 150 source code lines in the evaluation version
236: There is a limit of 150 source code lines in the evaluation version
237: There is a limit of 150 source code lines in the evaluation version
238: There is a limit of 150 source code lines in the evaluation version
239: There is a limit of 150 source code lines in the evaluation version
240: There is a limit of 150 source code lines in the evaluation version
241: There is a limit of 150 source code lines in the evaluation version
242: There is a limit of 150 source code lines in the evaluation version
243: There is a limit of 150 source code lines in the evaluation version
244: There is a limit of 150 source code lines in the evaluation version
245: There is a limit of 150 source code lines in the evaluation version
246: There is a limit of 150 source code lines in the evaluation version
247: There is a limit of 150 source code lines in the evaluation version
248: There is a limit of 150 source code lines in the evaluation version
249: There is a limit of 150 source code lines in the evaluation version
250: There is a limit of 150 source code lines in the evaluation version
251: There is a limit of 150 source code lines in the evaluation version
252: There is a limit of 150 source code lines in the evaluation version
253: There is a limit of 150 source code lines in the evaluation version

.NET Documentation Tool is © 2002 - 2009 Winnersh Triangle Web Solutions Limited.