AJH.CMS.Core.Data.HtmlBlockDataMapper.GetHtmlBlockById C# (CSharp) Method

GetHtmlBlockById() static private method

static private GetHtmlBlockById ( int HtmlBlockID ) : HtmlBlock
HtmlBlockID int
return AJH.CMS.Core.Entities.HtmlBlock
        internal static HtmlBlock GetHtmlBlockById(int HtmlBlockID)
        {
            HtmlBlock htmlBlock = null;

            using (SqlConnection sqlConnection = new SqlConnection(CMSCoreBase.CMSCoreConnectionString))
            {
                SqlCommand sqlCommand = new SqlCommand(SN_HTMLBLOCK_GET_BY_ID, sqlConnection);
                sqlCommand.CommandType = System.Data.CommandType.StoredProcedure;

                SqlParameter parameter = new SqlParameter(PN_HTMLBLOCK_ID, System.Data.SqlDbType.Int);
                parameter.Direction = System.Data.ParameterDirection.Input;
                parameter.Value = HtmlBlockID;
                sqlCommand.Parameters.Add(parameter);

                sqlCommand.Connection.Open();
                using (SqlDataReader reader = sqlCommand.ExecuteReader(System.Data.CommandBehavior.CloseConnection))
                {
                    while (reader.Read())
                    {
                        if (htmlBlock == null)
                            htmlBlock = new HtmlBlock();
                        FillFromReader(htmlBlock, reader);
                    }
                    reader.Close();
                    sqlCommand.Connection.Close();
                }
            }
            return htmlBlock;
        }