Exemple #1
0
        public ActionResult ChangePassword(CompteConfigViewModel CompteCVM)
        {
            using (WakilRecouvContext WakilContext = new WakilRecouvContext())
            {
                using (UnitOfWork UOW = new UnitOfWork(WakilContext))
                {
                    RoleService    RoleService = new RoleService(UOW);
                    EmployeService EmpService  = new EmployeService(UOW);

                    Employe e = EmpService.GetEmployeByUername(Session["username"].ToString());

                    if (e.Password == CompteCVM.Password)
                    {
                        e.Password        = CompteCVM.NewPassword;
                        e.ConfirmPassword = CompteCVM.NewPassword;

                        EmpService.Update(e);
                        EmpService.Commit();
                    }
                    else
                    {
                        ModelState.AddModelError("Password", "Votre mot de passe actuel est incorrect");
                    }

                    return(View());
                }
            }
        }
Exemple #2
0
        public ActionResult InscriptionCompte(Employe emp)
        {
            using (WakilRecouvContext WakilContext = new WakilRecouvContext())
            {
                using (UnitOfWork UOW = new UnitOfWork(WakilContext))
                {
                    RoleService    RoleService = new RoleService(UOW);
                    EmployeService EmpService  = new EmployeService(UOW);

                    var Roles = RoleService.GetAll();
                    ViewBag.RoleList = new SelectList(Roles, "RoleId", "role");

                    if (EmpService.GetEmployeByUername(emp.Username) != null)
                    {
                        ModelState.AddModelError("Username", "Nom d'utilisateur existe deja !");
                    }
                    else
                    {
                        EmpService.Add(emp);
                        EmpService.Commit();
                        return(RedirectToAction("Login"));
                    }

                    //Response.Write("<script>alert('" + emp.RoleId + "')</script>");
                    return(View());
                }
            }
        }
Exemple #3
0
        public ActionResult UpdateAccount(int id, Employe e)
        {
            using (WakilRecouvContext WakilContext = new WakilRecouvContext())
            {
                using (UnitOfWork UOW = new UnitOfWork(WakilContext))
                {
                    EmployeService EmpService  = new EmployeService(UOW);
                    RoleService    RoleService = new RoleService(UOW);

                    var Roles = RoleService.GetAll();
                    ViewBag.RoleList = new SelectList(Roles, "RoleId", "role");

                    Employe emp = EmpService.GetById(id);
                    emp.RoleId          = e.RoleId;
                    emp.IsVerified      = e.IsVerified;
                    emp.ConfirmPassword = emp.Password;

                    EmpService.Update(emp);
                    EmpService.Commit();

                    return(View("AccountList", EmpService.GetAll()));
                }
            }
        }