ODM AD Advanced Mappings

I was wondering if someone can give me some examples of advanced mappings in Directory Sync (On Demand AD). I have come from an AD Sync Pro back ground and although I have been through the ODM AD Course etc I am having a hard job translating how I used to do these formulas.

I am looking to change the UPN format from firstname@domain  to firstname.lastname@domain. In AD Pro I would have completed the following for example -

CASE WHEN EntryType=”Contact” THEN

              CASE WHEN Firstname is NULL OR LastName is Null THEN

                            dbo.ReplaceDomain(P.UserPrincipalName,P.TargetDomain)

              ELSE

                             LTRIM(RTRIM(FirstName + “.” + LastName+”@”))

              END

ELSE

              CASE WHEN EntryType='Contact' THEN

                            dbo.ReplaceDomain(P.InternetAddress,P.TargetDomain)

              ELSE

                            dbo.ReplaceDomain(P.UserPrincipalName,P.TargetDomain)

              END

END

I have gone through the Advanced Mapping Guide but still struggling to translate this into VALUE and CONDITION etc. I think once I can see this one displayed in the ODM AD Format then it will click and I will be able to translate any other formulas I used to use.