public JsonResult GetRecipeData(string productName, string EquipID, string ID) { var result = RecipeClass.getData(productName, EquipID, ID); Dictionary <string, object> response = new Dictionary <string, object>(); List <RecipeObject> obj = new List <RecipeObject>(); int counter = 0; string type = EquipmentModels.GetEquipmentTypeByID(Convert.ToInt32(ID)); if (type == "") { var child = EquipmentModels.getChildEquipments(EquipID); if (child == null) { counter = 0; } else { if (child.Count > 0) { counter = child.Count; } else { counter = 0; } } } else { counter = 1; } try { if (result.Rows.Count > 0) { foreach (DataRow dr in result.Rows) { var temp_obj = new RecipeObject(); temp_obj.RecipeID = dr["RecipeID"].ToString(); temp_obj.RecipeName = dr["RecipeName"].ToString(); temp_obj.RecipeBody = dr["RecipeBody"].ToString(); temp_obj.ProductName = dr["ProductName"].ToString(); temp_obj.EquipID = dr["EquipID"].ToString(); temp_obj.Counter = counter; DataTable dt = new DataTable(); dt = RecipeClass.getParams(dr["RecipeID"].ToString()); List <string> lstGroupName = new List <string>(); List <string> lstParameterName = new List <string>(); List <string> lstMin = new List <string>(); List <string> lstMax = new List <string>(); List <string> lstValue = new List <string>(); if (dt != null) { if (dt.Rows.Count > 0) { foreach (DataRow dr2 in dt.Rows) { lstGroupName.Add(dr2["GroupName"].ToString()); lstParameterName.Add(dr2["ParameterName"].ToString()); lstMin.Add(dr2["Min"].ToString()); lstMax.Add(dr2["Max"].ToString()); lstValue.Add(dr2["Value"].ToString()); } } } temp_obj.GroupName = lstGroupName; temp_obj.ParameterName = lstParameterName; temp_obj.Min = lstMin; temp_obj.Max = lstMax; temp_obj.Value = lstValue; obj.Add(temp_obj); } } else { obj = null; } } catch { obj = null; } return(Json(obj, JsonRequestBehavior.AllowGet)); }