public ActionResult StartTest(CandidateViewModel candidate) { ExamManagerEF examManager = examUtil.GetExamManager(); examManager.LoggedInUser = candidate; examUtil.SetExamManager(examManager); return this.RedirectToAction("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; }
public RegisterViewModel RegisterUser(RegisterViewModel registerViewModel) { OnlineExamAppDBEntities3 dbContext = new OnlineExamAppDBEntities3(); User existingUser = dbContext.Users.Where(u => u.UserName == registerViewModel.UserName).FirstOrDefault(); if (existingUser == null) { User user = new User(); user.FirstName = registerViewModel.FirstName; user.LastName = registerViewModel.LastName; user.UserName = registerViewModel.UserName; user.Password = registerViewModel.Password; dbContext.Users.Add(user); dbContext.SaveChanges(); _candidate = new ViewModel.CandidateViewModel() { Name = registerViewModel.UserName }; registerViewModel.ErrorDescription = string.Empty; } else registerViewModel.ErrorDescription = "The User Name already exists. Please supply a new User Name"; return registerViewModel; }