public ExceptionDialogViewModel() { ConfirmCommand = new RelayCommand(() => { Messenger.Default.Send(new HideExceptionDialogMessage(this)); }); }
public async void InitializeData() { AddNewPerformanceCommand = new RelayCommand(() => { Messenger.Default.Send(new ShowDialogMessage(Locator.PerformanceEditViewModel)); }); DeletePerformanceCommand = new RelayCommand<PerformanceViewModel>(p => { var result = _adminAccessBll.RemovePerformance(BllAccessHandler.SessionToken, p.ToDomainObject<Performance>()); if (!result) return; Performances.Remove(p); AddNotification(p, NotificationType.Removed); }); EditPerformanceCommand = new RelayCommand<PerformanceViewModel>(p => { Locator.PerformanceEditViewModel.InitializePreset( p.VenueViewModel, p.ArtistViewModel, p.DateTime); Messenger.Default.Send(new ShowDialogMessage(Locator.PerformanceEditViewModel)); }); SendNotificationsCommand = new RelayCommand(async () => { if (NotificationCollection != null) { foreach (var notify in NotificationCollection) { var sb = new StringBuilder(); foreach (var message in notify.Value) { switch (message.NotificationType) { case NotificationType.Add: sb.Append("The following event has been assigned: \n"); break; case NotificationType.Modified: sb.Append("The following event has changed: \n"); break; case NotificationType.Removed: sb.Append("The following event has been canceled: \n"); break; } sb.Append("Artist: ").Append(message.Performance.ArtistViewModel.Name).AppendLine() .Append("Venue: ").Append(message.Performance.VenueViewModel.Name) .Append(", ") .Append(message.Performance.VenueViewModel.Location.Name).AppendLine() .Append("Date: ") .Append(message.Performance.DateTimeViewModel.DateTime.ToString("dd-MM-yyyy HH:mm")) .AppendLine().AppendLine().Append("---------------------------"); } var tmp = new Notification { Recipient = notify.Key, Sender = BllAccessHandler.SessionToken?.User?.EMail, Subject = $"UFO administration notification", Body = sb.ToString() }; await _adminAccessBll.SendNotificationAsync(BllAccessHandler.SessionToken, tmp); } } NotificationCollection = null; }); await Dispatcher.CurrentDispatcher.InvokeAsync(async () => { var dates = await _viewAccessBll.GetAllPerformanceDatesAsync(); CurrentPerformanceDateTime = dates.FirstOrDefault(); foreach (var dateTime in dates) { PerformanceDates.Add(dateTime); } }); }