public void Save(Coment aComent)
 {
     SqlConnection sqlConnection = new SqlConnection(conStr);
     string query = "INSERT INTO tbl_coment(description,date_time,post_id,user_id) VALUES('" + aComent.Description + "','" + aComent.DateTime + "','" + aComent.PostId + "','"+aComent.UseId+"')";
     SqlCommand sqlCommand = new SqlCommand(query, sqlConnection);
     sqlConnection.Open();
     int row = sqlCommand.ExecuteNonQuery();
     sqlConnection.Close();
 }
        protected void commentButton_Click(object sender, EventArgs e)
        {
            if (Session["username"] != null || Session["Email"] != null)
            {

            Coment aComent = new Coment();
            ComentManager aComentManager = new ComentManager();
            aComent.Description = commentTextBox.Text;
            aComent.DateTime = DateTime.Now.ToString();
            aComent.PostId = postId;
            aComent.UseId = userId;
            aComentManager.Save(aComent);
            aUserManager.GetAllUserById(aComent.UseId);
            }
            else
            {

                msg.Text = "By Login first please!";

            }
        }
 public List<Coment> GetAllComentByPostId(int postId)
 {
     SqlConnection sqlConnection = new SqlConnection(conStr);
     string query = "SELECT *FROM tbl_coment WHERE post_id= '" + postId + "'";
     SqlCommand aSqlCommand = new SqlCommand(query,sqlConnection);
     sqlConnection.Open();
     SqlDataReader aSqlDataReader = aSqlCommand.ExecuteReader();
     List<Coment> coments = new List<Coment>();
     while (aSqlDataReader.Read())
     {
         Coment aComent = new Coment();
         aComent.Id = Convert.ToInt32(aSqlDataReader["Id"]);
         aComent.DateTime = aSqlDataReader["date_time"].ToString();
         aComent.Description = aSqlDataReader["description"].ToString();
         aComent.PostId = Convert.ToInt32(aSqlDataReader["post_id"]);
         aComent.UseId = Convert.ToInt32(aSqlDataReader["user_id"]);
         coments.Add(aComent);
     }
     aSqlDataReader.Close();
     sqlConnection.Close();
     return coments;
 }
 public void Save(Coment aComent)
 {
     aComentDbGateway.Save(aComent);
 }