public int InsertFaqComment(FaqCommentModel faqCommentModel) { SqlConnection connection = new SqlConnection(connectionString); string query = "INSERT INTO FAQ(Title, Comment) VALUES('" + faqCommentModel.Title + "','" + faqCommentModel.Comment + "')"; SqlCommand command = new SqlCommand(query, connection); connection.Open(); int rowAffected = command.ExecuteNonQuery(); connection.Close(); return(rowAffected); }
protected void submitButton_Click(object sender, EventArgs e) { string jqueryString = @"<script src='https://cdnjs.cloudflare.com/ajax/libs/jquery-confirm/3.2.0/jquery-confirm.min.js'>$.alert({title: 'Alert!',content: 'Please answer all the question and then submit.'});</script>"; this.ClientScript.RegisterClientScriptBlock(this.GetType(), "Jquery", jqueryString, false); string faqCommentTitle = commentTitleInputBox.Value; string faqComment = commentTextArea.Value; FaqCommentModel faqCommentModel = new FaqCommentModel(faqCommentTitle, faqComment); int rowsAffected = _faqManager.InsertFaqComment(faqCommentModel); System.Threading.Thread.Sleep(4000); Response.Redirect("FAQ.aspx"); }
public List <FaqCommentModel> GetFaqComment() { SqlConnection connection = new SqlConnection(connectionString); string query = "SELECT * FROM FAQ ORDER BY Id DESC"; SqlCommand command = new SqlCommand(query, connection); List <FaqCommentModel> faqCommentList = new List <FaqCommentModel>(); connection.Open(); SqlDataReader reader = command.ExecuteReader(); while (reader.Read()) { int id = int.Parse(reader["Id"].ToString()); string faqCommentTitle = reader["Title"].ToString(); string faqComment = reader["Comment"].ToString(); FaqCommentModel faqCommentModel = new FaqCommentModel(id, faqCommentTitle, faqComment); faqCommentList.Add(faqCommentModel); } connection.Close(); return(faqCommentList); }
public int InsertFaqComment(FaqCommentModel faqCommentModel) { return(_faqGateway.InsertFaqComment(faqCommentModel)); }