I have an MVC5 project. On my page I have 4 checkboxes and a search button. When the button is clicked, an ajax call is triggered to call the function below:
[HttpPost]
public ActionResult GetOpenOrders(ProductionStatus pStatus)
{
List<vw_orders> orderList = new List<vw_orders>();
OrderRepository orderRepo = new OrderRepository();
// Get the total list of open orders
orderList = orderRepo.getAllByStatus("V");
// If not all values are 0, we have to filter
// (allZero is a private function that checks if all property values of pStatus are 0)
if(allZero(productieStatus) != true)
{
// Only use the properties of pStatus where
// the value is 1
// example: pStatus.A = 1, pStatus.B = 0, pStatus.C = 1
orderList = orderList.Where( p => if(pStatus.A == 1) p.a == pStatus.A || if(pStatus.B == 1) p.b == pStatus.B || if(pStatus.C == 1) p.c = pStatus.C);
}
// return some json of orderList.ToList()
}
How can I add the OR condition conditionally to my WHERE clause, thus only when value of pStatus.property == 1 ?