Subversion Repository Public Repository

ChrisCompleteCodeTrunk

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
using ActionTireCo.Crm.Model.Database;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace ActionTireCo.Crm.Model.ModelExtensionMethods
{
    public static class ExtensionMethods
    {
        public static string GetFormattedAddress(this Customer customer)
        {
            string result = String.Empty;
            if (customer.AddressLine1 != null)
                result += customer.AddressLine1 + ",";
            if (customer.AddressLine2 != null)
                result += customer.AddressLine2 + ",";
            if (customer.City != null)
                result += customer.City + ",";
            if (customer.State != null)
                result += customer.State + ",";
            if (customer.Zip != null)
                result += customer.Zip;
            return result.Trim();
        }


        public static string GetFormattedPhoneNumber(this PhoneNumber phoneNumber)
        {
            return String.Format("{0:(###) ###-####}", new object[] { Int64.Parse(phoneNumber.Value) });
        }

        public static string GetFormattedPostalAddress(this PostalAddress postalAddress)
        {
            string result = string.Empty;
            if (postalAddress.AddressLine1 != null && postalAddress.AddressLine1.Length > 0)

                result += postalAddress.AddressLine1 + "<br>";

            if (postalAddress.AddressLine2 != null && postalAddress.AddressLine2.Length > 0)

                result += postalAddress.AddressLine2 + "<br>";

            if (postalAddress.AddressLine3 != null && postalAddress.AddressLine3.Length > 0)

                result += postalAddress.AddressLine3 + "<br>";

            if (postalAddress != null)
            {
                if (postalAddress.City != null && postalAddress.State != null && postalAddress.City != null)

                    result += String.Format("{0} {1}, {2}", new object[] { postalAddress.City, postalAddress.State, postalAddress.ZipCode });

            }
            return result;
        }

    }
}

Commits for ChrisCompleteCodeTrunk/ActionTireCo/ActionTireCo.Crm/Model/ModelExtensionMethods.cs

Diff revisions: vs.
Revision Author Commited Message
1 BBDSCHRIS picture BBDSCHRIS Wed 22 Aug, 2018 20:08:03 +0000