public override void Update() { if (Selected != null) { RoleEmployeItemViewModel itemToUpate = Selected; RoleEmployeItemWindow window = new RoleEmployeItemWindow(itemToUpate); window.ShowDialog(); if (window.DialogResult.HasValue && window.DialogResult == true) { try { RoleEmploye toUpdate = itemToUpate.ToEntity(); MyDb.SaveChanges(); ReloadDatas(); return; } catch (Exception e) { MessageBox.Show("Erreur lors de la sauvegarde des données : " + e.Message); } } MyDb = new MegaProductionBDDEntities(); } }
public override void Delete() { if (Selected != null) { if (MessageBox.Show("Souhaitez-vous réellement supprimer cet élément ?", "Suppression", MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.Yes) { try { RoleEmploye toRemove = Selected.ToEntity(); MyDb.RoleEmploye.Remove(toRemove); MyDb.SaveChanges(); ReloadDatas(); return; } catch (Exception e) { MessageBox.Show("Erreur lors de la sauvegarde des données : " + e.Message); } } MyDb = new MegaProductionBDDEntities(); } }
public RoleEmploye ToEntity() { RoleEmploye toReturn = associated_entity; toReturn.Libelle = Libelle; return(toReturn); }
public RoleEmployeItemViewModel(RoleEmploye roleEmploye, MegaProductionBDDEntities MyDb) { if (roleEmploye == null) { roleEmploye = new RoleEmploye(); } this.associated_entity = roleEmploye; this.Identifiant = roleEmploye?.Identifiant ?? 0; this.Libelle = roleEmploye?.Libelle; ValiderCommand = new RelayCommand(Valider); CancelCommand = new RelayCommand(Annuler); }
public override void Add() { RoleEmployeItemViewModel itemToAdd = new RoleEmployeItemViewModel(null, MyDb); RoleEmployeItemWindow window = new RoleEmployeItemWindow(itemToAdd); window.ShowDialog(); if (window.DialogResult.HasValue && window.DialogResult == true) { try { RoleEmploye toAdd = itemToAdd.ToEntity(); MyDb.RoleEmploye.Add(toAdd); MyDb.SaveChanges(); ReloadDatas(); return; } catch (Exception e) { MessageBox.Show("Erreur lors de la sauvegarde des données : " + e.Message); } } MyDb = new MegaProductionBDDEntities(); }