Hi alibasha,
Please check the below example and modify your code.
VB.Net
Private ASTERISK As Char = ","c
Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)
Dim currentPolicyLob As String = "GeneralLiability,Property,Umbrella,Test,test1"
Dim value As Boolean = DiamondScoreCheckForOdType(currentPolicyLob, "", DateTime.Now)
End Sub
Private Function DiamondScoreCheckForOdType(ByVal currentPolicyLob As String, ByVal predominantState As String, ByVal policyEffectiveDate As DateTime) As Boolean
Dim listOfLobForDiamondScoreRule As HashSet(Of String) = New HashSet(Of String)() From {
{"Auto"},{"AutoNonDealer"},{"Garage"},{"GeneralLiability"},{"InlandMarine"},{"PesticideHerbicide"},{"Property"},{"Umbrella"}}
Dim lobList As List(Of String) = New List(Of String)()
lobList = currentPolicyLob.Split(ASTERISK).ToList()
' Count without loop.
Dim eligibleLobCheckCounter As Integer = lobList.Where(Function(t2) listOfLobForDiamondScoreRule.Any(Function(t1) t2.Contains(t1))).Count()
If (eligibleLobCheckCounter > 0) Then
Dim isStateAndEffDateEligible As Boolean = (New LobCO.Shared.COShared).IsStateRuleApplicable(getLineOfBusiness(Lob.LineOfBusiness.Common), predominantState,policyEffectiveDate,DiamondScoreRuleCheckForOdType)
Return isStateAndEffDateEligible
End If
Return False
End Function
C#
char ASTERISK = ',';
protected void Page_Load(object sender, EventArgs e)
{
string currentPolicyLob = "GeneralLiability,Property,Umbrella,Test,test1";
bool value = DiamondScoreCheckForOdType(currentPolicyLob, "", DateTime.Now);
}
private bool DiamondScoreCheckForOdType(string currentPolicyLob, string predominantState, DateTime policyEffectiveDate)
{
HashSet<string> listOfLobForDiamondScoreRule = new HashSet<string>() {
{ "Auto" },
{ "AutoNonDealer" },
{ "Garage" },
{ "GeneralLiability" },
{ "InlandMarine" },
{ "PesticideHerbicide" },
{ "Property" },
{ "Umbrella" } };
List<string> lobList = new List<string>();
lobList = currentPolicyLob.Split(ASTERISK).ToList();
// Count without loop.
int eligibleLobCheckCounter = lobList.Where(t2 => listOfLobForDiamondScoreRule.Any(t1 => t2.Contains(t1))).Count();
if ((eligibleLobCheckCounter > 0))
{
bool isStateAndEffDateEligible = (new LobCO.Shared.COShared()).IsStateRuleApplicable(getLineOfBusiness(Lob.LineOfBusiness.Common), predominantState, policyEffectiveDate, DiamondScoreRuleCheckForOdType);
return isStateAndEffDateEligible;
}
return false;
}