public CustomAlert GetAlertByType(AlertType type, string valueSpecific = null) { AlertValue value; if (!string.IsNullOrEmpty(valueSpecific)) { value = _config.Alerts.FirstOrDefault(a => a.Enabled == true && a.AlertType == type && a.Value.ToLower().Trim() == valueSpecific.ToLower().Trim()); } else { value = _config.Alerts.FirstOrDefault(a => a.Enabled == true && a.AlertType == type); } if (value != null) { var alert = Alerts.FirstOrDefault(ca => ca.Descriptor != null && (ca.Descriptor.alertName == value.Value || ca.Descriptor.channelPointsName == value.Value)); return(alert); } return(null); }