public ActionResult Login(User_LoginModel u) { if (ModelState.IsValid) { string strEmail = u.Email; string strPassword = u.Pass; var User = db.Users.Where(x => x.Email == strEmail.ToUpper() && x.Pass == strPassword).FirstOrDefault(); //Verify credentials against database in real project if (User != null) { FormsAuthentication.SetAuthCookie(User.ID.ToString(), true); return(RedirectToAction("Index", "Admin")); } else { ModelState.AddModelError("authenticationError", "User name or Password is wrong. Try it again"); } } else { ModelState.AddModelError("modelStateValidEror", "An Error Occured Please Contact With System Admin !"); } return(View(u)); }
public async Task <IActionResult> Add(User_LoginModel user_Login) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } await _LoginRepository.AddAsync(new User_Login { User_Login_EmailAddress = user_Login.User_Login_EmailAddress, User_Login_Name = user_Login.User_Login_Name, User_Login_PassWord = user_Login.User_Login_PassWord, User_Login_Right = user_Login.User_Login_Right, User_Login_Sex = user_Login.User_Login_Sex, User_Login_State = user_Login.User_Login_State }); return(RedirectToAction("Index")); }