I have three different fields like name address phone number.
We need to compare three fields with other three fields (name 1,addrss1, phone number 1)
If name<> name1, address<>address 1, phone number<>phone number 1
Throw exception
But if any of the field has null value
For example: if name and name1 is null other two are different throw BE
Iflif name and name1 , address and address1 is null other two are different
throw BE
If (name Is Nothing AndAlso name1 Is Nothing) AndAlso (address <> address1 OrElse phoneNumber <> phoneNumber1) Then
Throw New BusinessRuleException("Fields are different where name fields are null.")
ElseIf (name Is Nothing AndAlso name1 Is Nothing) AndAlso (address Is Nothing AndAlso address1 Is Nothing) AndAlso phoneNumber <> phoneNumber1 Then
Throw New BusinessRuleException("Fields are different where name and address fields are null.")
ElseIf (name <> name1 OrElse address <> address1 OrElse phoneNumber <> phoneNumber1) Then
Throw New BusinessRuleException("Fields are different.")
End If
Start
|
If (String.IsNullOrEmpty(name) AndAlso String.IsNullOrEmpty(name1) AndAlso (address <> address1 OrElse phoneNumber <> phoneNumber1))
|-- True: Throw BusinessRuleException("Name fields are null but other fields are different.")
|-- False: Proceed to next If condition
|
If (String.IsNullOrEmpty(name) AndAlso String.IsNullOrEmpty(name1) AndAlso String.IsNullOrEmpty(address) AndAlso String.IsNullOrEmpty(address1) AndAlso (phoneNumber <> phoneNumber1))
|-- True: Throw BusinessRuleException("Name and Address fields are null but Phone Numbers are different.")
|-- False: Proceed to next If condition
|
If ((Not String.IsNullOrEmpty(name) AndAlso name <> name1) OrElse (Not String.IsNullOrEmpty(address) AndAlso address <> address1) OrElse (Not String.IsNullOrEmpty(phoneNumber) AndAlso phoneNumber <> phoneNumber1))
|-- True: Throw BusinessRuleException("One or more fields differ from their corresponding fields.")
|-- False: Continue Workflow
|
End