Imports Business
Imports Model
Imports Telerik.OpenAccess

Public Class Service1
    Implements IService1

    Public Function IService1_GetContacts() As ObjectContainer.ChangeSet Implements IService1.GetContacts
        Return ContactBO.GetContacts()
    End Function

    Public Function IService1_GetContactGroups() As ObjectContainer.ChangeSet Implements IService1.GetContactGroups
        Return ContactBO.GetContactGroups()
    End Function

    Public Function IService1_SaveContacts(ByVal changeset As ObjectContainer.ChangeSet) As ObjectContainer.ChangeSet Implements IService1.SaveContacts
        Return ContactBO.SaveContacts(changeset)
    End Function

    Private Shared Function GetChangeSet(ByVal listName As String, _
         ByVal scope As IObjectScope, _
         ByVal queryable As Object) As ObjectContainer.ChangeSet

        Dim container As New ObjectContainer()

        ' define the fetch groups used in the copy, by default all columns
        Dim collector As IObjectCollector = _
     New FetchGroupCollector(FetchGroupCollector.DefaultFetchGroup)

        container.CopyFrom(scope, queryable.[GetType]().Name, _
     queryable, collector)

        ' get everything in the container as a changeset
        Dim changeSet As ObjectContainer.ChangeSet = container.GetContent()

        Return changeSet
    End Function

End Class