Imports EDSL.Entities
Imports EDSL.DAL
Public Partial Class NewsArticleControl
Inherits System.Web.UI.UserControl
    Dim subcategory As New Integer
    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        Dim objNewsItem As New entMainNews
       
        objNewsItem = GetItem(Convert.ToInt32(Request.QueryString("id")))
        Dim breadcrumblabel As String
        Dim breadcrumbNavigate As String
        Dim breadTitle As String
        Dim objMainCategory As New dbMainCategory

        If Request.QueryString("ns") <> "" Then
            subcategory = Request.QueryString("ns")
        End If
        If Convert.ToInt32(Request.QueryString("n")) > 0 Then
            If Convert.ToInt32(Request.QueryString("n")) > 0 And (Request.QueryString("ns") <> "" And Request.QueryString("ns") > 0) Then
                Dim category As entmainCategory = objMainCategory.GetItem(Convert.ToInt32(Request.QueryString("ns")))
                'Find page control for meta description
                DirectCast(Me.Page, NewsArticle).SetMetaData("", category.CategoryName.ToString() & " News | " & objNewsItem.NewsHeadline.ToString())
                'Get parent name
                Dim parentCat As entmainCategory = objMainCategory.GetItem(Convert.ToInt32(Request.QueryString("n")))
                Dim masterPage As main = DirectCast(Me.Page.Master, main)
                masterPage.BodyTag.Attributes.Add("class", parentCat.DropDownValue.ToString())
                breadcrumblabel = category.CategoryName & " News Articles"
            Else

                Dim category As entmainCategory = objMainCategory.GetItem(Convert.ToInt32(Request.QueryString("n")))
                'Find page control for meta description
                DirectCast(Me.Page, NewsArticle).SetMetaData("", category.CategoryName.ToString() & " News | " & objNewsItem.NewsHeadline.ToString())
                'Find div on master page
                Dim masterPage As main = DirectCast(Me.Page.Master, main)
                masterPage.BodyTag.Attributes.Add("class", category.DropDownValue.ToString())
                breadcrumblabel = category.CategoryName & " News Articles"

            End If

        Else
            breadcrumblabel = "General News Articles"
            DirectCast(Me.Page, NewsArticle).SetMetaData("", "General News | " & objNewsItem.NewsHeadline.ToString())
        End If
        breadcrumbNavigate = "~/news/lastestnews.html?n=" & Request.QueryString("n") & "&ns=" & subcategory
        breadTitle = "&nbsp;&nbsp;&raquo;&nbsp;&nbsp; <a>" & objNewsItem.NewsHeadline & "</a> "
        CType(Me.Parent.FindControl("breadcrumb"), Breadcrumb).SetHyperLinkField(breadcrumbNavigate, breadcrumblabel, breadTitle)

        Dim lbl As Label = Me.Parent.FindControl("labelPageTitle")
        lbl.Text = objNewsItem.NewsHeadline

        Dim strOutput As String = ""

        Dim booMainImage As Boolean = False
        If objNewsItem.MainImage <> "" Then
            booMainImage = True
        End If
        lblNewsText.Text = CheckStringValue(objNewsItem.NewsText)
        HyperLink1.NavigateUrl = "~/news/lastestnews.html?n=" & Request.QueryString("n") & "&ns=" & subcategory
        If booMainImage = True Then
            imgArticle.Visible = True
            imgArticle.ImageUrl = ConfigurationManager.AppSettings("UploadFileURL") & "images/" & objNewsItem.MainImage.ToString()
            imgArticle.AlternateText = objNewsItem.NewsHeadline.ToString()


        End If


    End Sub
   
    Private Function CheckStringValue(ByVal strInput As String) As String
        Dim strOutput As String = ""
        If Not strInput Is Nothing AndAlso strInput <> "" Then
            strOutput = strInput
        End If
        Return strOutput
    End Function

    Private newPropertyValue As String
    Public Property NewProperty() As String
        Get
            Return newPropertyValue
        End Get
        Set(ByVal value As String)
            newPropertyValue = value
        End Set
    End Property

 

    Private Function GetItem(ByVal newsID As Integer) As entMainNews
        Dim objMain As New dbMainNews
        Dim objMainEntity As entMainNews = objMain.GetItem(newsID)
        Return objMainEntity
    End Function

End Class
