public void UpdateCategorie() { CategorieDataService cds = new CategorieDataService(); ValidationMessage = "This field is required."; // controleren of het veld "naam" is ingevuld met validatie if (MyValidation.ControleForm(SelectedCategorie.Naam)) { return; } else { ValidationMessage = ""; // controleren of de categorie al bestaat in de database string _categorieBestaat = cds.CategorieNaamExist(SelectedCategorie.Naam); if (_categorieBestaat != null) { MessageBox.Show("This Category already exists.", "Information", MessageBoxButton.OK, MessageBoxImage.Information); } else { // controleren of update of insert moet zijn if (SelectedCategorie.Id == 0) { cds.InsertCategorie(SelectedCategorie); Messenger.Default.Send <UpdateFinishedMessage>(new UpdateFinishedMessage(UpdateFinishedMessage.MessageType.Inserted)); } else { cds.UpdateCategorie(SelectedCategorie); Messenger.Default.Send <UpdateFinishedMessage>(new UpdateFinishedMessage(UpdateFinishedMessage.MessageType.Updated)); } } } }
//dialog vensters private void OnMessageReceived(UpdateFinishedMessage message) { if (message.Type == UpdateFinishedMessage.MessageType.Updated) { _dialogService.CloseCategorieDetailDialog(); } if (message.Type == UpdateFinishedMessage.MessageType.Deleted || message.Type == UpdateFinishedMessage.MessageType.Inserted) { CategorieDataService cds = new CategorieDataService(); Categories = cds.GetCategories(); _dialogService.CloseCategorieDetailDialog(); } }
public void DeleteCategorie() { MessageBoxResult result = MessageBox.Show("When you delete a Category, all Algorithms from this Category will be removed too." + "\n" + "By removing a Algorithm, all Results from this Algorithm will be deleted too." + "\n" + " Are you sure you want to delete this Category ?", "Delete Category?", MessageBoxButton.YesNo, MessageBoxImage.Warning, MessageBoxResult.No); switch (result) { case MessageBoxResult.Yes: CategorieDataService cds = new CategorieDataService(); cds.DeleteCategorie(SelectedCategorie); Messenger.Default.Send <UpdateFinishedMessage>(new UpdateFinishedMessage(UpdateFinishedMessage.MessageType.Deleted)); break; } }
//*****CONSTRUCTOR***** public CategorieWindowViewModel() { //laden data CategorieDataService cds = new CategorieDataService(); Categories = cds.GetCategories(); //koppelen commands ExitCommand = new BaseCommand(Exit); WijzigCategorieCommand = new BaseCommand(WijzigCategorie); VoegCategorieToeCommand = new BaseCommand(VoegCategorieToe); //instantiëren DialogService als singleton _dialogService = new DialogService(); //luisteren naar updates vanuit categorieDetail Messenger.Default.Register <UpdateFinishedMessage>(this, OnMessageReceived); }
//*****CONSTRUCTOR***** public AlgorithmDetailWindowViewModel() { //laden data CategorieDataService cds = new CategorieDataService(); Categories = cds.GetCategories(); //koppelen commands UpdateCommand = new BaseCommand(UpdateAlgorithm); DeleteCommand = new BaseCommand(DeleteAlgorithm); LoadImageCommand = new BaseCommand(LoadImage); //instantiëren DialogService als singleton _dialogService = new DialogService(); //luisteren naar updates Messenger.Default.Register <Algorithm>(this, OnAlgorithmReceived); }