示例#1
0
        public bool ChangeComment(int id, CommentEntity comment)
        {
            using (var connection = new MySqlConnection(AppConfig.ConnectionString))
            {
                var command = new MySqlCommand
                {
                    Connection  = connection,
                    CommandType = CommandType.StoredProcedure,
                    CommandText = "ChangeComment"
                };

                command.Parameters.AddWithValue("@commentId", id);
                comment.SetCommandParameters(command);

                connection.Open();
                return(command.ExecuteNonQuery() > 0);
            }
        }
示例#2
0
        public int AddComment(CommentEntity comment)
        {
            using (var connection = new MySqlConnection(AppConfig.ConnectionString))
            {
                var command = new MySqlCommand
                {
                    Connection  = connection,
                    CommandType = CommandType.StoredProcedure,
                    CommandText = "AddComment"
                };

                comment.SetCommandParameters(command);

                connection.Open();
                var reader = command.ExecuteReader();

                if (reader.Read())
                {
                    return(int.Parse(reader["id"].ToString()));
                }

                return(-1);
            }
        }