public ActionResult NewUser(CustomerAccount model) { ViewBag.HideContact = true; ViewBag.HideFAQ = true; ViewBag.HideBack = true; ViewBag.HideHome = true; ModelState.Clear(); ViewBag.Success = false; var accountDetails = new AccountService(); model.LastLoginDate = new DateTime(1900, 01, 01); model.Email = model.Email; //validation if (string.IsNullOrEmpty(model.Password) || string.IsNullOrEmpty(model.Email)) { ModelState.Clear(); ModelState.AddModelError("Email", "Empty User or Password."); return(View(model)); } Log.File.InfoFormat(string.Format("Date : {1}| Email : {0} ", model.Email, DateTime.Now)); var user = new CustomerAccount(); user = accountDetails.GetCustomerAccountDetails(model.Email, model.PostCode, model.ClientCustRef); // if (user != null) { ModelState.Clear(); ModelState.AddModelError("Password", "User already exist."); } bool validation = ValidatePassword(model.Password); if (!validation) { ModelState.Clear(); ModelState.AddModelError("ConfirmPassword", "Your password must be at least 8 characters in length and contain at least one number, please try again. "); } bool comparePassword = ComparePasswords(model.Password, model.ConfirmPassword); if (!comparePassword) { ModelState.Clear(); ModelState.AddModelError("Password", "Both passwords don’t match, please try again."); } if (ModelState.IsValid) { // user levels var accDetails = new CustomerAccount(); accDetails.InjectFrom(model); accDetails.Password = model.Password; AccountService.AddNewCustomerAccount(accDetails); AccountService.UpdateCustomerEnrolment(AccountService.SessionInfo.EnroleId); AccountService.InsertUserTryCount(model.Email); accService.Authenticate(customerService.SessionInfo.CustomerID, (accDetails.Email)); return(RedirectToAction("Details", "Customer")); } else { Log.File.ErrorFormat(string.Format("Date : {1}| Email : {0} : Returning to signin page from NewUser ", model.Email, DateTime.Now)); return(View(model)); } }