Imports EDSL.Entities
Imports EDSL.DAL


Partial Public Class Testimonial
    Inherits System.Web.UI.UserControl

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

        Dim caseStudyType As New Integer
        Dim productID As New Integer
        Dim categoryID As New Integer
  

        'Check that the page is category only

        If Request.QueryString("pid") = "" Then
            'Get the category
            If Request.QueryString("cid") <> "" Then
                caseStudyType = Convert.ToInt32(Request.QueryString("cid"))
                GetCaseStudyDetails(caseStudyType, 0, categoryID)
            End If


            If Request.QueryString("id") = "1" Then
                caseStudyType = Convert.ToInt32(Request.QueryString("id"))
                GetCaseStudyDetails(caseStudyType, 0, categoryID)
            End If
            'Default testimonial
            If caseStudyType = 0 Then
                GetCaseStudyDetails(0, 0, categoryID)
            End If
        Else
            caseStudyType = Convert.ToInt32(Request.QueryString("cid"))
            productID = Convert.ToInt32(Request.QueryString("pid"))

            GetCaseStudyDetails(caseStudyType, productID, categoryID)
        End If
    End Sub
    Private Sub GetCaseStudyDetails(ByVal id As Integer, ByVal productID As Integer, ByVal parentID As Integer)
        Dim func As New miscFunctions
        Dim main As New dbMainTestimonial
        Dim caseStudy As New entMainTestimonial
        If productID > 0 Then
            caseStudy = main.GetItemSideBar_Product(id, productID)
        Else
            If id > 0 Then
                caseStudy = main.GetItemSideBar(id)
            Else
                caseStudy = main.GetItemSideBar_Random()
            End If

        End If

        If Not caseStudy.CaseStudyID Is Nothing And caseStudy.Testimonial <> "" Then
            With caseStudy
                lblTestimonial.Text = .Testimonial
                lblTestimonialSignature.Text = .TestimonialSignature
            End With
        Else

            With caseStudy
                lblTestimonial.Text = .Testimonial
                lblTestimonialSignature.Text = .TestimonialSignature
            End With
        End If

    End Sub

End Class