Component Page /Comments.cs (C#)
1: using System;  
2: using Microsoft.ApplicationBlocks.Data;  
3: using System.Data.SqlClient;  
4: using System.Data;  
5:   
6: namespace QuizNetOnline.Logic  
7: {  
8:     [Serializable]  
9:     public class Comments  
10:     {  
11:         private static Comments _instance;  
12:         private string _comment;  
13:   
14:         private int _questionid;  
15:         private string _userName;  
16:   
17:         public static Comments Instance  
18:         {  
19:             get { return _instance ?? (_instance = new Comments()); }  
20:         }  
21:   
22:         public int QuestionId  
23:         {  
24:             get { return _questionid; }  
25:             set { _questionid = value; }  
26:         }  
27:   
28:         public string Comment  
29:         {  
30:             get { return _comment; }  
31:             set { _comment = value; }  
32:         }  
33:   
34:         public string UserName  
35:         {  
36:             get { return _userName; }  
37:             set { _userName = value; }  
38:         }  
39:   
40:         public bool Save(ISqlWrapper iSqlWrapper)  
41:         {  
42:             string connStr = iSqlWrapper.GetConnectionString();  
43:             const string sproc = "CreateComment";  
44:   
45:             var parameters = new SqlParameter[4];  
46:   
47:             parameters[0] = new SqlParameter("@QuestionID", QuestionId);  
48:             parameters[1] = new SqlParameter("@Comment", Comment);  
49:             parameters[2] = new SqlParameter("@UserName", UserName);  
50:             parameters[3] = new SqlParameter("@newId", 0);  
51:   
52:             try  
53:             {  
54:                 iSqlWrapper.ExecuteNonQuery(connStr, CommandType.StoredProcedure, sproc, parameters);  
55:                 return true;  
56:             }  
57:             catch (Exception ex)  
58:             {  
59:                 ErrorLog errorLog = new ErrorLog();  
60:                 errorLog.LogException("Comments Save", ex, iSqlWrapper);  
61:                 throw;  
62:             }  
63:         }  
64:   
65:         public static bool ClearComments(ISqlWrapper iSqlWrapper)  
66:         {  
67:             string connStr = iSqlWrapper.GetConnectionString();  
68:             const string sproc = "DeleteComment";  
69:   
70:             try  
71:             {  
72:                 iSqlWrapper.ExecuteNonQuery(connStr, CommandType.StoredProcedure, sproc);  
73:                 return true;  
74:             }  
75:             catch (Exception ex)  
76:             {  
77:                 ErrorLog errorLog = new ErrorLog();  
78:                 errorLog.LogException("ClearComments", ex, iSqlWrapper);  
79:                 throw;  
80:             }  
81:         }  
82:     }  
83: }  

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