Пример #1
0
        public static string ToHtmlString(this DBML.address row)
        {
            if (row == null)
            {
                return("");
            }

            var hasValue = false;

            var sb = new StringBuilder();

            sb.Append("<ul style=\"list-style: none outside none;\">");
            if (!string.IsNullOrEmpty(row.first_name) && !string.IsNullOrEmpty(row.last_name))
            {
                sb.AppendFormat("<li>{0} {1}</li>", row.first_name, row.last_name);
                hasValue = true;
            }

            if (!string.IsNullOrEmpty(row.organisation_name))
            {
                sb.AppendFormat("<li>{0}</li>", row.organisation_name);
                hasValue = true;
            }

            if (!string.IsNullOrEmpty(row.street_address))
            {
                sb.AppendFormat("<li>{0}</li>", row.street_address.ToHtmlBreak());
                hasValue = true;
            }

            sb.AppendFormat("<li>{0}</li><li>{1} {2}</li>",
                            row.city,
                            row.state.ToStateName(row.country.HasValue ? row.country.Value.ToString() : ""),
                            row.postcode);


            if (row.country.HasValue)
            {
                sb.AppendFormat("<li>{0}</li>", Country.GetCountry(row.country.Value).name);
                hasValue = true;
            }

            sb.Append("</ul>");

            if (!hasValue)
            {
                return("");
            }

            return(sb.ToString());
        }
Пример #2
0
        public static Address ToModel(this DBML.address row)
        {
            if (row == null)
            {
                return(new Address());
            }

            return(new Address()
            {
                firstName = row.first_name,
                lastName = row.last_name,
                companyName = row.organisation_name,
                streetAddress = row.street_address,
                city = row.city,
                postcode = row.postcode,
                state = row.state,
                countryid = row.country,
                country = row.country.ToCountry().name,
                phone = row.phone
            });
        }