Click here to Skip to main content
15,884,237 members
Articles / Programming Languages / Visual Basic

PeopleTrac – People Management for Not-For-Profit Organizations

Rate me:
Please Sign up or sign in to vote.
4.91/5 (10 votes)
3 Jan 2012CPOL6 min read 24K   877   13  
Demonstrates several LightSwitch capabilities including WCF-RIA services, Native SQL, Name and Addres merge purge

Namespace LightSwitchApplication

    Public Class ApplicationDataService

        Private Sub Subscriptions_Updating(entity As Subscription)


        End Sub

       
        Private Sub ActiveSeasons_PreprocessQuery(ByRef query As System.Linq.IQueryable(Of LightSwitchApplication.Season))
            'query = From mySeason In query
            '        Where mySeason.Year >= Date.Today.Year - 3
            '        Select mySeason
        End Sub

        Private Sub MailListGeneral_PreprocessQuery(ByRef query As System.Linq.IQueryable(Of LightSwitchApplication.Person))
            'query = From myList In query
            '        Select myList.NamePrefix, myList.FirstName, myList.LastName, _
            '        myList.Address1, myList.Address2, myList.City, myList.State, myList.Zip
        End Sub

        Private Sub PeopleCountsByMailcode_PreprocessQuery(ByRef query As System.Linq.IQueryable(Of LightSwitchApplication.Person))
            'SELECT TOP (100) PERCENT MAX(dbo.People.Id) AS ID, dbo.MailCodes.MailCodeName, COUNT(dbo.People.Id) AS Count
            'FROM  dbo.People INNER JOIN
            '               dbo.MailCodes ON dbo.People.Person_MailCode = dbo.MailCodes.Id
            'GROUP BY dbo.MailCodes.MailCodeName
            'ORDER BY dbo.MailCodes.MailCodeName

           
        End Sub

        Private Sub ImportPersons_Validate(entity As ImportPerson, results As EntitySetValidationResultsBuilder)
            If entity.BestPrimaryMatchID Is Nothing Then
                entity.BestPrimaryMatchID = 0
            End If
            If entity.BestPrimaryMatchScore Is Nothing Then
                entity.BestPrimaryMatchScore = 0
            End If
            If entity.ExistingPersonLastName Is Nothing Then
                entity.ExistingPersonLastName = "No match"
            End If
            If entity.ExistingPersonAddress1 Is Nothing Then
                entity.ExistingPersonAddress1 = "No match"
            End If
            If entity.ExistingPersonAddress2 Is Nothing Then
                entity.ExistingPersonAddress2 = "No match"
            End If
            If entity.ExistingPersonCity Is Nothing Then
                entity.ExistingPersonCity = "No Match"
            End If
            If entity.ExistingPersonZip Is Nothing Then
                entity.ExistingPersonZip = "No match"
            End If
            If entity.Address2 Is Nothing Then
                entity.Address2 = ""
            End If
            If entity.BusinessPhone Is Nothing Then
                entity.BusinessPhone = ""
            End If
            If entity.City Is Nothing Then
                entity.City = ""
            End If
            If entity.Company Is Nothing Then
                entity.Company = ""
            End If
            If entity.Donation Is Nothing Then
                entity.Donation = 0
            End If
            If entity.Email Is Nothing Then
                entity.Email = ""
            End If
            If entity.HomePhone Is Nothing Then
                entity.HomePhone = ""
            End If
            If entity.MatchesExistingPerson Is Nothing Then
                entity.MatchesExistingPerson = False
            End If
            If entity.UpdateAddress Is Nothing Then
                entity.UpdateAddress = False
            End If
            If entity.MobilPhone Is Nothing Then
                entity.MobilPhone = ""
            End If
            If entity.NameSuffix Is Nothing Then
                entity.NameSuffix = ""
            End If
            If entity.Salutation Is Nothing Then
                entity.Salutation = ""
            End If
            If entity.State Is Nothing Then
                entity.State = ""
            End If
            If entity.SubscriptionQty Is Nothing Or
              entity.SubscriptionQty < 1 Then
                entity.SubscriptionQty = 1
            End If

        End Sub

        Private Sub People_Validate(entity As Person, results As Microsoft.LightSwitch.EntitySetValidationResultsBuilder)
            If entity.Address2 Is Nothing Then
                entity.Address2 = ""
            End If
            If entity.BusinessPhone Is Nothing Then
                entity.BusinessPhone = ""
            End If
            If entity.City Is Nothing Then
                entity.City = ""
            End If
            If entity.Company Is Nothing Then
                entity.Company = ""
            End If
            If entity.Email Is Nothing Then
                entity.Email = ""
            End If
            If entity.HomePhone Is Nothing Then
                entity.HomePhone = ""
            End If
            If entity.MobilPhone Is Nothing Then
                entity.MobilPhone = ""
            End If
            If entity.NameSuffix Is Nothing Then
                entity.NameSuffix = ""
            End If
            If entity.Salutation Is Nothing Then
                entity.Salutation = ""
            End If
        End Sub

        Private Sub ExternalMailPersons_Validate(entity As ExternalMailPerson, results As EntitySetValidationResultsBuilder)
            If entity.BestPrimaryMatchID Is Nothing Then
                entity.BestPrimaryMatchID = 0
            End If
            If entity.BestPrimaryMatchScore Is Nothing Then
                entity.BestPrimaryMatchScore = 0
            End If
            If entity.ExistingPersonLastName Is Nothing Then
                entity.ExistingPersonLastName = "No match"
            End If
            If entity.ExistingPersonAddress1 Is Nothing Then
                entity.ExistingPersonAddress1 = "No match"
            End If
            If entity.ExistingPersonAddress2 Is Nothing Then
                entity.ExistingPersonAddress2 = "No match"
            End If
            If entity.ExistingPersonCity Is Nothing Then
                entity.ExistingPersonCity = "No Match"
            End If
            If entity.ExistingPersonZip Is Nothing Then
                entity.ExistingPersonZip = "No match"
            End If
            If entity.Address2 Is Nothing Then
                entity.Address2 = ""
            End If

            If entity.City Is Nothing Then
                entity.City = ""
            End If
            If entity.Company Is Nothing Then
                entity.Company = ""
            End If

            If entity.MatchesExistingPerson Is Nothing Then
                entity.MatchesExistingPerson = False
            End If

            If entity.NameSuffix Is Nothing Then
                entity.NameSuffix = ""
            End If
            If entity.Salutation Is Nothing Then
                entity.Salutation = ""
            End If
            If entity.State Is Nothing Then
                entity.State = ""
            End If
        End Sub
    End Class

End Namespace

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
United States United States
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions