Пример #1
0
 public BaseListViewModel()
 {
     MyDb               = new MegaProductionBDDEntities();
     this.AddCommand    = new RelayCommand(Add);
     this.UpdateCommand = new RelayCommand(Update);
     this.DeleteCommand = new RelayCommand(Delete);
 }
        public override void Delete()
        {
            if (Selected != null)
            {
                if (MessageBox.Show("Voulez-vous réellement supprimer cet élément ? ",
                                    "Suppression",
                                    MessageBoxButton.YesNo,
                                    MessageBoxImage.Question) == MessageBoxResult.Yes)
                {
                    try
                    {
                        Offre toRemove = Selected.ToEntity();
                        MyDb.Offre.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 override void Update()
        {
            if (Selected != null)
            {
                OffreItemViewModel item   = Selected;
                OffreItemWindow    window = new OffreItemWindow(item);
                window.ShowDialog();

                if (window.DialogResult.HasValue && window.DialogResult == true)
                {
                    try
                    {
                        Offre toUpdate = Selected.ToEntity();
                        MyDb.SaveChanges();
                        ReloadDatas();
                        return;
                    }
                    catch (Exception e)
                    {
                        MessageBox.Show("Erreur lors de la sauvegarde : " + e.Message);
                    }
                }
                MyDb = new MegaProductionBDDEntities();
            }
        }
Пример #4
0
        private void Valider()
        {
            //hash le mot de passe avec SHA512 pour le comparer à la bdd
            SHA512 shaM = new SHA512Managed();

            byte[] passwordHashed = shaM.ComputeHash(stringToByte(Mot_De_Passe));

            string passe = Encoding.UTF8.GetString(passwordHashed);

            //Verifier utilisateur
            MegaProductionBDDEntities MyDB = new MegaProductionBDDEntities();

            if (MyDB.Employe.Any(x =>
                                 x.Nom_Utilisateur == Nom_Utilisateur &&
                                 x.Mot_De_Passe == passe))
            {
                employeAConnecter = MyDB.Employe.First(x =>
                                                       x.Nom_Utilisateur == Nom_Utilisateur &&
                                                       x.Mot_De_Passe == passe);
                windowAssociee.Close();
            }
            else
            {
                MessageBox.Show("Mauvaise combinaison utilisateur / mdp");
            }
        }
        public override void Add()
        {
            PartenaireDiffusionItemViewModel item   = new PartenaireDiffusionItemViewModel(null);
            PartenaireDiffusionItemWindow    window = new PartenaireDiffusionItemWindow(item);

            window.ShowDialog();

            if (window.DialogResult.HasValue && window.DialogResult == true)
            {
                try
                {
                    PartenaireDiffusion toAdd = item.ToEntity();
                    MyDb.PartenaireDiffusion.Add(toAdd);
                    MyDb.SaveChanges();
                    ReloadDatas();
                    return;
                }
                catch (Exception e)
                {
                    MessageBox.Show("Erreur lors de la sauvegarde des données : " + e.Message);
                }
            }

            MyDb = new MegaProductionBDDEntities();
        }
Пример #6
0
        public override void Update()
        {
            if (Selected != null)
            {
                ContenuEditorialItemViewModel itemToUpate = Selected;
                ContenuEditorialItemWindow    window      = new ContenuEditorialItemWindow(itemToUpate);
                window.ShowDialog();

                if (window.DialogResult.HasValue && window.DialogResult == true)
                {
                    try
                    {
                        ContenuEditorial 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ééllement supprimer cet élément ?",
                             "Suppresion",
                             MessageBoxButton.YesNo,
                             MessageBoxImage.Question) == MessageBoxResult.Yes)
         {
             try
             {
                 Casting itemToDelete = Selected.ToEntity();
                 MyDb.Casting.Remove(itemToDelete);
                 MyDb.SaveChanges();
                 ReloadDatas();
                 return;
             }
             catch (Exception ex)
             {
                 MessageBox.Show("Erreur lors de la sauvegarde des données : " + ex.Message);
             }
             //Erreur à la suppression
             MyDb = new MegaProductionBDDEntities();
         }
     }
 }
        public override void Update()
        {
            if (Selected != null)
            {
                //Ouverture de la fenêtre d'ajout
                CastingItemViewModel itemToUpdate = Selected;
                CastingItemWindow    window       = new CastingItemWindow(itemToUpdate);
                window.ShowDialog();

                if (window.DialogResult.HasValue && window.DialogResult == true)
                {
                    //On a appuyé sur OK
                    //Sauvegarde
                    try
                    {
                        Casting toAdd = itemToUpdate.ToEntity();
                        MyDb.SaveChanges();
                        ReloadDatas();
                        return;
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show("Erreur lors de la sauvegarde des données : " + ex.Message);
                    }
                }
                //On a appuyé sur annuler ou on a crash dans la sauvegrde de l'item
                MyDb = new MegaProductionBDDEntities();
            }
        }
        public DomaineItemViewModel(Domaine domaine, MegaProductionBDDEntities MyDb)
        {
            if (domaine == null)
            {
                domaine = new Domaine();
            }

            this.associated_entity = domaine;

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

            ValiderCommand = new RelayCommand(Valider);
            CancelCommand  = new RelayCommand(Annuler);
        }
Пример #10
0
        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 ContenuEditorialItemViewModel(ContenuEditorial contenu, MegaProductionBDDEntities DB)
        {
            if (contenu == null)
            {
                contenu = new ContenuEditorial();
            }
            this.associated_entity = contenu;

            this.Identifiant            = contenu?.Identifiant ?? 0;
            this.Titre                  = contenu?.Titre;
            this.Date_Publication       = contenu?.Date_Publication;
            this.TypeContenuSelectionne = contenu?.TypeContenuEditorial;
            ValiderCommand              = new RelayCommand(Valider);
            CancelCommand               = new RelayCommand(Annuler);

            this.LstTypes           = DB.TypeContenuEditorial.ToList();
            this.LibelleTypeContenu = contenu?.TypeContenuEditorial?.Libelle;
        }
        public MetierItemViewModel(Metier metier, MegaProductionBDDEntities MyDb)
        {
            if (metier == null)
            {
                metier = new Metier();
            }

            this.associated_entity = metier;

            this.Identifiant        = metier?.Identifiant ?? 0;
            this.Libelle            = metier?.Libelle;
            this.DomaineSelectionne = metier?.Domaine1;

            this.LstDomaines    = MyDb.Domaine.ToList();
            this.LibelleDomaine = metier?.Domaine1?.Libelle;

            ValiderCommand = new RelayCommand(Valider);
            CancelCommand  = new RelayCommand(Annuler);
        }
Пример #13
0
        public override void Delete()
        {
            if (Selected != null)
            {
                if (MessageBox.Show("Souhaitez-vous rééllement supprimer cet élément ?",
                                    "Suppresion",
                                    MessageBoxButton.YesNo,
                                    MessageBoxImage.Question) == MessageBoxResult.Yes)
                {
                    try
                    {
                        Annonceur itemToDelete = Selected.ToEntity();

                        /*if (itemToDelete.Employe_Createur.Any())
                         * {
                         *  MessageBox.Show("Suppression impossible car il y a un employe associé");
                         *  return;
                         * }
                         * if (itemToDelete.Metier.Any())
                         * {
                         *  MessageBox.Show("Suppression impossible car il existe un métier associé");
                         *  return;
                         * }
                         * if (itemToDelete.Annonceur.Any())
                         * {
                         *  MessageBox.Show("Suppression impossible car il existe des annonceurs associés");
                         *  return;
                         * }*/
                        MyDb.Annonceur.Remove(itemToDelete);
                        MyDb.SaveChanges();
                        ReloadDatas();
                        return;
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show("Erreur lors de la sauvegarde des données : " + ex.Message);
                    }
                    //Erreur à la suppression
                    MyDb = new MegaProductionBDDEntities();
                }
            }
        }
        public EmployeItemViewModel(Employe employe, MegaProductionBDDEntities DB)
        {
            if (employe == null)
            {
                employe = new Employe();
            }
            this.associated_entity = employe;

            this.Identifiant     = employe?.Identifiant ?? 0;
            this.Nom             = employe?.Nom;
            this.Prenom          = employe?.Prenom;
            this.Mail            = employe?.Mail;
            this.Nom_Utilisateur = employe?.Nom_Utilisateur;
            this.Mot_De_Passe    = employe?.Mot_De_Passe;
            this.RoleSelectionne = employe?.RoleEmploye;

            this.LstRoles    = DB.RoleEmploye.ToList();
            this.LibelleRole = employe?.RoleEmploye?.Libelle;

            ValiderCommand = new RelayCommand(Valider);
            CancelCommand  = new RelayCommand(Annuler);
        }
        public CastingItemViewModel(Casting casting, MegaProductionBDDEntities MyDb)
        {
            if (casting == null)
            {
                casting = new Casting();
            }
            this.associated_entity = casting;

            this.Identifiant = casting?.Identifiant ?? 0;
            this.Libelle     = casting?.Libelle;
            //Initialisé à des valeurs par défaut car pas récupéré de la bdd
            this.Date_Debut_Publication = casting?.Date_Debut_Publication;
            this.Nb_Jour_Diffusion      = casting.Nb_Jour_Diffusion;
            this.Date_Debut_Contrat     = casting?.Date_Debut_Contrat;
            this.Nb_Poste             = casting?.Nb_Poste;
            this.Description_Poste    = casting?.Description_Poste;
            this.Description_Profil   = casting?.Description_Profil;
            this.Type_Contrat         = casting?.Type_Contrat;
            this.Adresse_Contrat      = casting?.Adresse_Contrat;
            this.AnnonceurSelectionne = casting?.Annonceur1;
            this.EmployeSelectionne   = casting?.Employe1;
            this.MetierSelectionne    = casting?.Metier1;

            this.LstAnnonceurs = MyDb.Annonceur.ToList();
            int nbAnn = MyDb.Annonceur.ToList().Count;

            this.Employes = MyDb.Employe.ToList();
            this.Metiers  = MyDb.Metier.ToList();


            this.LibelleAnnonceur = casting?.Annonceur1?.Libelle;
            this.EmployeUserName  = casting?.Employe1?.Nom_Utilisateur;
            this.LibelleMetier    = casting?.Metier1?.Libelle;


            ValiderCommand = new RelayCommand(Valider);
            CancelCommand  = new RelayCommand(Annuler);
        }
Пример #16
0
        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();
        }
Пример #17
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);
        }