public UserService(RecruteContext entities)
 {
     this.entities = entities;
 }
 public UserController()
 {
     context = new RecruteContext();
     userservice = new UserService();
 }
        public ActionResult Login(User user)
        {
            if (ModelState.IsValid)
            {
                using (RecruteContext contex = new RecruteContext())
                {
                    var v = contex.Users.Where(a => a.email.Equals(user.email) && a.password.Equals(user.password)).FirstOrDefault();
                    if (v != null)
                    {
                        Session["LogedUserID"] = v.userID.ToString();
                        Session["LogedUserFirstname"] = v.userFirstName.ToString();
                        Session["LogedUserName"] = v.userName.ToString();
                        Session["LoggedUserRole"] = Roles.GetRolesForUser(v.email);
                        FormsAuthentication.SetAuthCookie(v.email, false);
                        return RedirectToAction("Details", "User", new { id = v.userID });
                    }
                }
            }
                else
                {
                    ModelState.AddModelError("Erreur", "Email ou Mot de passe invalides!");
                }

            return View();
        }
 private bool ValidateUser(string Email, string Password)
 {
     bool isValid = false;
     using (var db = new RecruteContext())
     {
             var v = db.Users.Where(a => a.email.Equals(Email) && a.password.Equals(Password)).FirstOrDefault();
             if (v != null)
             {
                 Session["LogedUserID"] = v.userID.ToString();
                 Session["LogedUserFirstname"] = v.userFirstName.ToString();
                 Session["LogedUserName"] = v.userName.ToString();
                 isValid = true;
             }
     }
     return isValid;
 }
        public override bool ValidateUser(string email, string password)
        {
            bool isValid = false;
            if (string.IsNullOrEmpty(email) || string.IsNullOrEmpty(password))
                return false;

            using (var context = new RecruteContext())
            {
                var user = context.Users.Where(a => a.email.Equals(email) && a.password.Equals(password)).FirstOrDefault();
                if (user != null) { isValid = true;}
                return isValid;
            }
        }