Example #1
0
 public ActionResult AdminLogin(UserAccount u)
 {
     // this action is for handle post (login)
     if (ModelState.IsValid) // this is check validity
     {
         using (HRM_DatabaseEntities dc = new HRM_DatabaseEntities())
         {
             var v = dc.UserAccounts.Where(a => a.username.Equals(u.username) && a.password.Equals(u.password) && a.UserType.Equals("Admin")).FirstOrDefault();
             if (v != null)
             {
                 Session["LogedUserID"]       = v.userId.ToString();
                 Session["LogedUserFullname"] = v.username.ToString();
                 return(RedirectToAction("Registration", "User"));
             }
             else if (v == null)
             {
                 TempData["wrong"] = "Username Or Password Invalid Please Try Again!";
             }
             //else
             //{
             //    ModelState.AddModelError("", "The user name or password provided is incorrect.");
             //}
         }
     }
     return(View(u));
 }
Example #2
0
 public ActionResult ForgetUserPassword(UserAccount u)
 {
     if (ModelState.IsValid)
     {
         using (HRM_DatabaseEntities dc = new HRM_DatabaseEntities())
         {
             var v = dc.UserAccounts.Where(a => a.username.Equals(u.username) && a.email.Equals(u.email) && a.UserType.Equals("User")).FirstOrDefault();
             if (v != null)
             {
                 Session["forgetUserID"]       = v.userId.ToString();
                 Session["forgetUserFullname"] = v.username.ToString();
                 Session["forgetEmail"]        = v.email.ToList();
                 return(RedirectToAction("ConfirmUserNewPassword", "Admin"));
             }
         }
     }
     return(View());
 }