Public Class clsSiteSEO
    ''' <summary>
    ''' 获取单条记录
    ''' </summary>
    ''' <param name="ID"></param>
    ''' <returns></returns>
    ''' <remarks></remarks>
    Public Function GetSingle(ByVal ID As Integer) As SiteSEO
        Using db As New DB_ConfigsDataContext
            Return (From c In db.SiteSEO _
                    Where c.ID = ID _
                    Select c).FirstOrDefault
        End Using
    End Function
    ''' <summary>
    ''' 获取所有记录
    ''' </summary>
    ''' <returns></returns>
    ''' <remarks></remarks>
    Public Shared Function GetLinq(ByVal SiteID As Integer) As IQueryable(Of SiteSEO)
        Dim db As New DB_ConfigsDataContext
        Return From c In db.SiteSEO _
               Where c.SiteID = SiteID _
               Order By c.ID _
               Select c
    End Function
    ''' <summary>
    ''' 删除单个实例
    ''' </summary>
    ''' <param name="ID"></param>
    ''' <returns></returns>
    ''' <remarks></remarks>
    Public Function Delete(ByVal ID As Integer) As Boolean
        Using db As New DB_ConfigsDataContext
            Dim Del = (From d In db.SiteSEO _
                      Where d.ID = ID _
                      Select d).FirstOrDefault
            If Not IsNothing(Del) Then
                Dim mSiteID As Integer = Del.SiteID
                db.SiteSEO.DeleteOnSubmit(Del)
                Try
                    db.SubmitChanges()
                    IO.File.WriteAllText(Web.HttpContext.Current.Request.PhysicalApplicationPath & "CacheFile\SiteSEO" & mSiteID.ToString & ".txt", Now)
                    Return True
                Catch ex As Exception
                    Return False
                End Try
            Else
                Return False
            End If
        End Using
    End Function
    ''' <summary>
    ''' 删除多个实例
    ''' </summary>
    ''' <param name="ID"></param>
    ''' <returns></returns>
    ''' <remarks></remarks>
    Public Function Delete(ByVal ID() As Integer) As Boolean
        Using db As New DB_ConfigsDataContext
            Dim Del = From d In db.SiteSEO _
                      Where ID.Contains(d.ID) _
                      Select d
            Dim mSiteID As Integer
            For Each d In Del
                mSiteID = d.SiteID
                db.SiteSEO.DeleteOnSubmit(d)
            Next
            Try
                db.SubmitChanges()
                IO.File.WriteAllText(Web.HttpContext.Current.Request.PhysicalApplicationPath & "CacheFile\SiteSEO" & mSiteID.ToString & ".txt", Now)
                Return True
            Catch ex As Exception
                Return False
            End Try
        End Using
    End Function
    ''' <summary>
    ''' 添加
    ''' </summary>
    ''' <param name="BindType"></param>
    ''' <param name="BindID"></param>
    ''' <param name="PageTitle"></param>
    ''' <param name="KeyWords"></param>
    ''' <param name="Description"></param>
    ''' <returns></returns>
    ''' <remarks></remarks>
    Public Function Insert(ByVal BindType As Integer, ByVal BindID As Integer, ByVal PageTitle As String, ByVal KeyWords As String, ByVal Description As String, ByVal SEOName As String, ByVal SiteID As Integer) As Integer
        Using db As New DB_ConfigsDataContext
            Dim mNewSiteSEO As New SiteSEO With {.BindType = BindType, .BindID = BindID, .PageTitle = PageTitle, .KeyWords = KeyWords, .Description = Description, .SEOName = SEOName, .SiteID = SiteID}
            db.SiteSEO.InsertOnSubmit(mNewSiteSEO)
            Try
                db.SubmitChanges()
                IO.File.WriteAllText(Web.HttpContext.Current.Request.PhysicalApplicationPath & "CacheFile\SiteSEO" & SiteID.ToString & ".txt", Now)
                Return mNewSiteSEO.ID
            Catch ex As Exception
                Return 0
            End Try
        End Using
    End Function
    ''' <summary>
    ''' 保存
    ''' </summary>
    ''' <param name="BindType"></param>
    ''' <param name="BindID"></param>
    ''' <param name="PageTitle"></param>
    ''' <param name="KeyWords"></param>
    ''' <param name="Description"></param>
    ''' <returns></returns>
    ''' <remarks></remarks>
    Public Function Save(ByVal ID As Integer, ByVal BindType As Integer, ByVal BindID As Integer, ByVal PageTitle As String, ByVal KeyWords As String, ByVal Description As String, ByVal SEOName As String) As Integer
        Using db As New DB_ConfigsDataContext
            Dim UpdateSiteSEO = (From c In db.SiteSEO _
                                       Where c.ID = ID _
                                       Select c).FirstOrDefault
            If Not IsNothing(UpdateSiteSEO) Then
                With UpdateSiteSEO
                    .BindType = BindType
                    .BindID = BindID
                    .PageTitle = PageTitle
                    .KeyWords = KeyWords
                    .Description = Description
                    .SEOName = SEOName
                End With

                Try
                    db.SubmitChanges()
                    IO.File.WriteAllText(Web.HttpContext.Current.Request.PhysicalApplicationPath & "CacheFile\SiteSEO" & UpdateSiteSEO.SiteID.ToString & ".txt", Now)
                    Return 1
                Catch ex As Exception
                    Return 0
                End Try
            Else
                Return 0
            End If
        End Using
    End Function
End Class
