public ActionResult ChangePassword(ChangePassword changePassword) { if (ModelState.IsValid) { using (var context = new AssessmentEntities()) { var AdminRecord = context.spLOGIN(changePassword.UserName, changePassword.ExistingPassword).SingleOrDefault(); if (AdminRecord != null) { AdminRecord.ADMIN_PASSWORD = changePassword.NewPassword; context.SaveChanges(); ModelState.AddModelError("", "Password Changed Successfully"); } else { ModelState.AddModelError("", "Please enter correct password"); } } } return View(changePassword); }
public ActionResult Index(LoginViewModel model) { if (ModelState.IsValid) { using (var context = new AssessmentEntities()) { var userExist = context.spLOGIN(model.UserName, model.Password).ToList(); if (userExist.Count == 1) { FormsAuthentication.SetAuthCookie(model.UserName, false); return RedirectToAction("Index", "admin"); } else { ModelState.AddModelError("", "Log in credentials invalid"); } } } // If we got this far, something failed, redisplay form return View(model); }