public JsonResult DeleteEquipmentType(string ID) { var result = EquipTypeModels.DeleteEquipmentType(ID); DataTable dt = new DataTable(); if (result == true) { dt = EquipmentModels.GetEquipmentByType(ID); int count = 0; try { count = dt.Rows.Count; } catch { count = 0; } if (count > 0) { result = EquipmentModels.DeleteEquipmentByType(ID); } bool temp = result; if (result == true) { foreach (DataRow dr in dt.Rows) { int EquipID = Convert.ToInt32(dr["ID"].ToString()); result = UserEquipmentModels.DeleteUserEquipmentByBatch(EquipID.ToString()); if (result == true) { temp = true; } } } result = temp; } return(Json(result.ToString(), JsonRequestBehavior.AllowGet)); }