private async void AddNewException() { var exception = new Exception { Name = SingleExceptionName, Description = SingleExceptionDescription, Date = SingleExceptioDate, Schedule1 = SingleExceptionSchedule }; bool error = false; try { _dataService.AddException(exception); exceptions.Add(exception); } catch (System.Exception e) { error = true; } if (error) { var mainwindow = (Application.Current.MainWindow as MainWindow); await mainwindow.ShowMessageAsync("Sorry!", "A problem has accured trying to add the new exception."); } SingleExceptionName = ""; SingleExceptionDescription = ""; SingleExceptioDate = SingleExceptioDate.AddDays(1); SingleExceptionSchedule = null; (new ViewModelLocator()).Main.NewExceptionFlyoutStatus = false; (new ViewModelLocator()).Main.StartScheduler(); }