public override void Update()
        {
            if (Selected != null)
            {
                TypeContenuEditorialItemViewModel itemToUpate = Selected;
                TypeContenuEditorialItemWindow    window      = new TypeContenuEditorialItemWindow(itemToUpate);
                window.ShowDialog();

                if (window.DialogResult.HasValue && window.DialogResult == true)
                {
                    try
                    {
                        TypeContenuEditorial 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
             {
                 TypeContenuEditorial toRemove = Selected.ToEntity();
                 MyDb.TypeContenuEditorial.Remove(toRemove);
                 MyDb.SaveChanges();
                 ReloadDatas();
                 return;
             }
             catch (Exception e)
             {
                 MessageBox.Show("Erreur lors de la sauvegarde des données : " + e.Message);
             }
         }
         MyDb = new MegaProductionBDDEntities();
     }
 }
Exemplo n.º 3
0
        public TypeContenuEditorial ToEntity()
        {
            TypeContenuEditorial toReturn = associated_entity;

            toReturn.Libelle = Libelle;

            return(toReturn);
        }
Exemplo n.º 4
0
        public TypeContenuEditorialItemViewModel(TypeContenuEditorial typeContenuEditorial, MegaProductionBDDEntities MyDb)
        {
            if (typeContenuEditorial == null)
            {
                typeContenuEditorial = new TypeContenuEditorial();
            }

            this.associated_entity = typeContenuEditorial;

            this.Identifiant = typeContenuEditorial?.Identifiant ?? 0;
            this.Libelle     = typeContenuEditorial?.Libelle;

            ValiderCommand = new RelayCommand(Valider);
            CancelCommand  = new RelayCommand(Annuler);
        }