Component Page /UserFavourite.cs (C#)
1: using System;  
2: using System.Collections.Generic;  
3: using Microsoft.ApplicationBlocks.Data;  
4: using System.Data.SqlClient;  
5: using System.Data;  
6:   
7: namespace QuizNetOnline.Logic  
8: {  
9:     [Serializable]  
10:     public class UserFavourite  
11:     {  
12:         private List<Question> _questions;  
13:         private string _userName;  
14:   
15:         public string UserName  
16:         {  
17:             get { return _userName; }  
18:             set { _userName = value; }  
19:         }  
20:   
21:         public List<Question> Questions  
22:         {  
23:             get { return _questions; }  
24:             set { _questions = value; }  
25:         }  
26:   
27:         public int HasUserFavourites(string userName, ISqlWrapper isqlWrapper)  
28:         {  
29:             string connStr = isqlWrapper.GetConnectionString();  
30:   
31:             if (connStr == null)  
32:                 throw new NotImplementedException();  
33:   
34:             const string sproc = "GetHasUserFavourites";  
35:             var parameters = new SqlParameter[1];  
36:             parameters[0] = new SqlParameter("UserName", userName);  
37:             try  
38:             {  
39:                 var hasUserFavourites =  
40:                     (int)isqlWrapper.ExecuteScalar(connStr, CommandType.StoredProcedure, sproc, parameters);  
41:                 return hasUserFavourites;  
42:             }  
43:             catch (Exception ex)  
44:             {  
45:                 ErrorLog errorLog = new ErrorLog();  
46:                 errorLog.LogException("HasUserFavourites", ex, isqlWrapper);  
47:                 throw;  
48:             }  
49:         }  
50:   
51:         public virtual void Load(string userName, int? questionId, ISqlWrapper iSqlWrapper, Question question)  
52:         {  
53:             var questions = new List<Question>();  
54:             UserName = userName;  
55:   
56:             string connStr = iSqlWrapper.GetConnectionString();  
57:             new List<UserFavourite>();  
58:             const string sproc = "GetUserFavourites";  
59:             var parameters = new SqlParameter[2];  
60:             parameters[0] = new SqlParameter("@UserName", UserName);  
61:             parameters[1] = new SqlParameter("@QuestionID", questionId);  
62:             try  
63:             {  
64:                 DataSet ds = iSqlWrapper.ExecuteDataset(connStr, CommandType.StoredProcedure, sproc, parameters);  
65:   
66:                 if (ds.Tables.Count > 0)  
67:                 {  
68:                     DataTable tbl = ds.Tables[0];  
69:                     foreach (DataRow row in tbl.Rows)  
70:                     {  
71:                         question.LoadQuestion(Convert.ToInt32(row["QuestionID"].ToString()), iSqlWrapper);  
72:                         question = new Question();  
73:                         var _question = new Question();  
74:                         _question = question;  
75:                         questions.Add(_question);  
76:                     }  
77:   
78:                     Questions = questions;  
79:                 }  
80:             }  
81:             catch (Exception ex)  
82:             {  
83:                 ErrorLog errorLog = new ErrorLog();  
84:                 errorLog.LogException("GetUserFavourites", ex, iSqlWrapper);  
85:                 throw;  
86:             }  
87:         }  
88:   
89:         public List<Question> GetUserFavourites(ISqlWrapper isqlWrapper, int questionId, string userName)  
90:         {  
91:             var questions = new List<Question>();  
92:             UserName = userName;  
93:   
94:             string connStr = isqlWrapper.GetConnectionString();  
95:             new List<UserFavourite>();  
96:             const string sproc = "GetUserFavourites";  
97:             var parameters = new SqlParameter[2];  
98:             parameters[0] = new SqlParameter("@UserName", UserName);  
99:             parameters[1] = new SqlParameter("@QuestionID", questionId);  
100:             try  
101:             {  
102:                 DataSet ds = isqlWrapper.ExecuteDataset(connStr, CommandType.StoredProcedure, sproc, parameters);  
103:   
104:                 if (ds.Tables.Count > 0)  
105:                 {  
106:                     DataTable tbl = ds.Tables[0];  
107:                     Question question;  
108:                     foreach (DataRow row in tbl.Rows)  
109:                     {  
110:                         question = new Question();  
111:                         question.LoadQuestion(Convert.ToInt32(row["QuestionID"].ToString()), new SqlWrapper());  
112:                         questions.Add(question);  
113:                     }  
114:   
115:                     Questions = questions;  
116:                 }  
117:                 return questions;  
118:             }  
119:             catch (Exception ex)  
120:             {  
121:                 ErrorLog errorLog = new ErrorLog();  
122:                 errorLog.LogException("GetUserFavourites", ex, isqlWrapper);  
123:                 throw;  
124:             }  
125:         }  
126:   
127:         public bool Create(string userName, int questionId, ISqlWrapper iSqlWrapper)  
128:         {  
129:             if (userName == "guest@quiznetonline.com" || string.IsNullOrEmpty(userName)) return true;  
130:   
131:             string connStr = iSqlWrapper.GetConnectionString();  
132:   
133:             if (connStr == null)  
134:                 throw new NotImplementedException();  
135:   
136:   
137:             string sproc = "CreateUserFavourites";  
138:             var parameters = new SqlParameter[2];  
139:             parameters[0] = new SqlParameter("@UserName", userName);  
140:             parameters[1] = new SqlParameter("@QuestionID", questionId);  
141:             try  
142:             {  
143:                 iSqlWrapper.ExecuteNonQuery(connStr, CommandType.StoredProcedure, sproc, parameters);  
144:             }  
145:             catch (Exception ex)  
146:             {  
147:                 ErrorLog errorLog = new ErrorLog();  
148:                 errorLog.LogException("UserFavourite.Create", ex, iSqlWrapper);  
149:                 throw;  
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
254: There is a limit of 150 source code lines in the evaluation version
255: There is a limit of 150 source code lines in the evaluation version
256: There is a limit of 150 source code lines in the evaluation version
257: There is a limit of 150 source code lines in the evaluation version
258: There is a limit of 150 source code lines in the evaluation version

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