public ActionResult Login(LoginViewModel loginViewModel) { ExamManagerEF examManager = examUtil.GetExamManager(); LoginViewModel loginViewModelUpdated = examManager.Login(loginViewModel); if (!string.IsNullOrEmpty(loginViewModelUpdated.ErrorDescription)) return View(loginViewModelUpdated); else return this.RedirectToAction("Exam", "Exam"); }
public LoginViewModel Login(LoginViewModel loginViewModel) { OnlineExamAppDBEntities3 dbContext = new OnlineExamAppDBEntities3(); User existingUser = dbContext.Users.Where(u => u.UserName == loginViewModel.UserName && u.Password == loginViewModel.Password).FirstOrDefault(); if (existingUser != null) { _candidate = new ViewModel.CandidateViewModel() { Name = existingUser.FirstName }; loginViewModel.ErrorDescription = string.Empty; } else loginViewModel.ErrorDescription = "Unable to login. Please check the User Name and Password and try again !!"; return loginViewModel; }