private static string GetAddress(PostalAddressEntity entity) => new StringBuilder() .When(() => !string.IsNullOrWhiteSpace(entity?.Line1), sb => sb.Append(entity.Line1) .Append(!string.IsNullOrWhiteSpace(entity.Line2)? $", {entity.Line2}" : string.Empty) .Append(!string.IsNullOrWhiteSpace(entity.Line3)? $", {entity.Line3}" : string.Empty) .Append(!string.IsNullOrWhiteSpace(entity.Line4)? $", {entity.Line4}" : string.Empty) .Append(!string.IsNullOrWhiteSpace(entity.Line5)? $", {entity.Line5}" : string.Empty) .Append(!string.IsNullOrWhiteSpace(entity.Postcode)? $", {entity.Postcode.ToUpper()}" : string.Empty)).ToString();
private string GetAddress(PostalAddressEntity entity) { var builder = new StringBuilder(); if (!string.IsNullOrWhiteSpace(entity?.Line1)) { builder.Append(entity.Line1); builder.Append(!string.IsNullOrWhiteSpace(entity.Line2) ? $", {entity.Line2}" : string.Empty); builder.Append(!string.IsNullOrWhiteSpace(entity.Line3) ? $", {entity.Line3}" : string.Empty); builder.Append(!string.IsNullOrWhiteSpace(entity.Line4) ? $", {entity.Line4}" : string.Empty); builder.Append(!string.IsNullOrWhiteSpace(entity.Line5) ? $", {entity.Line5}" : string.Empty); builder.Append(!string.IsNullOrWhiteSpace(entity.Postcode) ? $", {entity.Postcode.ToUpper()}" : string.Empty); return(builder.ToString()); } return(string.Empty); }