private string GetAddressLine(Address add, int index)
 {
     if (add?.Lines?.Count > index)
     {
         var lines = add.Lines as AddressLine[];
         return lines[index].AddressLineText;
     }
     return string.Empty;
 }
 private Address GetNewAddress(string addressType)
 {
     string errorMessage = string.Format("Address type \"{0}\" not defined in lookup", addressType);
     var type = db.AddressTypes.FirstOrDefault(m => m.AddressTypeName == addressType);
     if (type == null)
         throw new Exception(errorMessage);
     var address = new Address();
     address.AddressType = type;
     address.AddressTypeID = type.AddressTypeId;
     address.Lines = new List<AddressLine>();
     address.Lines.Add(new AddressLine());
     address.Lines.Add(new AddressLine());
     address.Lines.Add(new AddressLine());
     address.Lines.Add(new AddressLine());
     address.Lines.Add(new AddressLine());
     return address;
 }