Example #1
0
        public ActionResult Create([Bind(Include = "idPers,nomPers,prenomPers,adressePers,dateNaissancePers,sexePers,cniPers,situationMatPers,emailPers,telPers,specialteInf")] InfirmierViewModel infirmierViewModel)
        {
            if (ModelState.IsValid)
            {
                Personne p = new Personne();
                p.adressePers       = infirmierViewModel.adressePers;
                p.cniPers           = infirmierViewModel.cniPers;
                p.dateNaissancePers = infirmierViewModel.dateNaissancePers;
                p.emailPers         = infirmierViewModel.emailPers;
                p.nomPers           = infirmierViewModel.nomPers;
                p.prenomPers        = infirmierViewModel.prenomPers;
                p.sexePers          = infirmierViewModel.sexePers;
                p.situationMatPers  = infirmierViewModel.situationMatPers;
                p.telPers           = infirmierViewModel.telPers;
                db.personnes.Add(p);
                db.SaveChanges();
                Infirmier inf = new Infirmier();
                inf.idInf        = p.idPers;
                inf.specialteInf = infirmierViewModel.specialteInf;
                db.infirmiers.Add(inf);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(infirmierViewModel));
        }
Example #2
0
        public ActionResult DeleteConfirmed(int id)
        {
            Infirmier inf = db.infirmiers.Find(id);

            db.infirmiers.Remove(inf);
            db.SaveChanges();
            Personne p = db.personnes.Find(id);

            db.personnes.Remove(p);
            db.SaveChanges();

            return(RedirectToAction("Index"));
        }