I have to calculate the price based on multiple input variables
public class Model
{
public int Account { get; set; }
public long Related{ get; set; }
public int TransactionType { get; set; }
public string detail{ get; set; }
public int PlanId { get; set; }
}
First switch starts with TransactionType
. Based on TransactionType
I need to use Account,PlanId ,Related
fields for more information from database to get more information and some configurable information. There are more conditions based on those database values. Of coarse there are some common logic and information required between different TransactionType
now i can use
switch (TransactionType)
{
case 1:
//Check Related value and get more information from database
//Apply buisness rule
//Check PlanId value and get more information from database
//Apply buisness rule
//Get final value
break;
case 2
//Check Related value and get more information from database
//Apply buisness rule
//Check PlanId value and get more information from database
//Apply buisness rule
//Get final value
break;
default:
break;
}
Please help me how i can avoid these switch statements
Aucun commentaire:
Enregistrer un commentaire