private Notification ConvertToNotification(Notif not, string eventType, DateTime date, string title) { Notification n = new Notification() { Notif_type = not.Type, Num_tel_ou_email = not.Type == "email" ? user.userMail : user.phoneNumber, Date_notif = not.time, Date_event = date, Event_type = eventType, Username = user.userName, Message = title }; return(n); }
private void AddAlarme(object sender, MouseButtonEventArgs e) { if (NotificationDict.Count == 3) { MessageBox.Show("trois notifications au max"); } else { if (DatePickeralarm.SelectedDate == null || TimePickeralarm.SelectedTime == null || ComboBoxAlarmType.SelectedIndex == -1) { MessageBox.Show("Veuillez remplir tous les champs"); return; } DateTime d = DatePickeralarm.SelectedDate.Value; DateTime t = TimePickeralarm.SelectedTime.Value; Notif n = new Notif() { time = new DateTime(d.Year, d.Month, d.Day, t.Hour, t.Minute, 0), Type = ComboBoxAlarmType.SelectedIndex == 0 ? "email" : "sms", }; Chip c = CreateAlarmChip($"{d.Year}-{d.Month}-{d.Date}-{t.Hour}:{t.Minute}"); bool b = false; foreach (Notif notif in NotificationDict.Values) { if (notif.time == n.time && notif.Type == n.Type) { b = true; break; } } if (!b) { NotificationDict[c] = n; alarmeChipsField.Children.Add(c); if (NotificationDict.Count == 3) { AddAlarme1.IsEnabled = false; } } else { MessageBox.Show("Alarme Dupliquée"); } } }