public void AddAlert(BackupProfileData profile, BackupPerfectAlertTypeEnum alert, string text = null) { var alertData = BackupPerfectAlertValueDictionary[alert](); alertData.AlertTime = DateTime.Now; if (text != null) { alertData.Name += text; } Application.Current.Dispatcher.Invoke(new Action(() => { if (alert.ToString().StartsWith("Restore")) { var foundAlert = profile.RestoreAlertList.FirstOrDefault(e => e.AlertType == alert); if (foundAlert == null) { profile.RestoreAlertList.Add(alertData); } } else { var foundAlert = profile.BackupAlertList.FirstOrDefault(e => e.AlertType == alert); if (foundAlert == null) { profile.BackupAlertList.Add(alertData); } } })); }
public void RemoveAlert(BackupProfileData profile, BackupPerfectAlertTypeEnum alert) { // var foundAlert = profile.BackupAlertList.FirstOrDefault(e => e.IsDeletable && e.AlertType == alert); var foundAlert = profile.BackupAlertList.FirstOrDefault(e => e.AlertType == alert); if (foundAlert != null) { Application.Current.Dispatcher.Invoke(new Action(() => { profile.BackupAlertList.Remove(foundAlert); })); } foundAlert = profile.RestoreAlertList.FirstOrDefault(e => e.IsDeletable && e.AlertType == alert); if (foundAlert != null) { Application.Current.Dispatcher.Invoke(new Action(() => { profile.RestoreAlertList.Remove(foundAlert); })); } }