Example #1
0
 public void updateFromView(UtilisateurView userview)
 {
     this.nom = userview.nom;
        this.prenom = userview.prenom;
        this.email = userview.email;
        this.id_groupe = userview.id_groupe;
        this.id_tache = userview.id_tache;
        this.id_role = userview.id_role;
        this.horaires_matin = userview.horaires_matin;
        this.horaires_matin_fin = userview.horaires_matin_fin;
        this.horaires_apresmidi = userview.horaires_apresmidi;
        this.horaires_apresmidi_fin = userview.horaires_apresmidi_fin;
        this.z_actif = true;
 }
Example #2
0
 public PartialViewResult Editer(int id)
 {
     ViewBag.type = "editer";
     employe employe = cnx.employe.Single(e => e.id_employe == id);
     UtilisateurView userview = new UtilisateurView();
     userview.updateFromModel(employe);
     ViewBag.id_groupe = new SelectList(cnx.groupe, "id_groupe", "nom", employe.id_groupe);
     ViewBag.id_role = new SelectList(cnx.role, "id_role", "role_description", employe.id_role);
     ViewBag.id_tache = new SelectList(cnx.tache, "id_tache", "nom_tache", employe.id_tache);
     return PartialView("_formUtilisateur", userview);
 }
Example #3
0
        public ActionResult Editer(UtilisateurView userview)
        {
            if (ModelState.IsValid)
            {
                employe emp;
                if (userview.id==null)
                {
                    emp = new employe();
                    utilisateur user = new utilisateur();
                    emp.utilisateur = user;
                    emp.utilisateur.mot_passe = this.RandomString();
                }
                else
                {
                   emp = cnx.employe.Where(e => e.id_employe == userview.id).Single();
                }
                emp.updateFromView(userview);
                emp.utilisateur.UpdateFromView(userview);
                if (emp.isUnique())
                {
                    if (userview.id == null)
                    {
                        cnx.employe.AddObject(emp);
                        cnx.SaveChanges();
                        // on envoie un email à l'employé
                        EmailInfoConnexion email = new EmailInfoConnexion(emp);
                        new MailController().BienvenueEmail(email).Deliver();
                    }
                    else
                    {
                        cnx.ObjectStateManager.ChangeObjectState(emp, EntityState.Modified);
                        cnx.SaveChanges();
                    }
                    return Json(new { succes = 1 });
                }
                else
                {
                    ModelState.AddModelError("", "Votre identifiant doit être unique");
                }

            }
            return Json(new { succes = 0, erreurs = ModelState.ListeErreurs() });
        }
Example #4
0
 public void UpdateFromView(UtilisateurView userview)
 {
     this.identifiant = userview.identifiant;
 }