public ActionResult CreateAgent(LoanViewModel lvm) { try { agent.ContactEmail = lvm.AgentModel.ContactEmail; var valid = DataReaders.ValidateAgent(agent.ContactEmail); if (valid == false) { TempData["Message"] = "Agent Already Exist!"; return(View("Index")); } else if (valid == true) { user.pasword = lvm.AccountsModel.pasword; user.confirmPassword = lvm.AccountsModel.confirmPassword; bool validatePass = DataReaders.ValidatePassword(user.pasword, user.confirmPassword); if (validatePass == true) { agent.ContactAddress = lvm.AgentModel.ContactAddress; user.pasword = lvm.AccountsModel.pasword; var EncrypPassword = new CryptographyManager().ComputeHash(user.pasword, HashName.SHA256); user.pasword = EncrypPassword; user.firstname = lvm.AgentModel.FirstName; user.lastname = lvm.AgentModel.LastName; user.Phone = lvm.AgentModel.PhoneNumber; user.Email = lvm.AgentModel.ContactEmail; agent.NextOfKinAddress = lvm.AgentModel.NextOfKinAddress; agent.NextOfKinName = lvm.AgentModel.NextOfKinName; agent.NextOfKinPhoneNumber = lvm.AgentModel.NextOfKinPhoneNumber; agent.LastName = lvm.AgentModel.LastName; agent.FirstName = lvm.AgentModel.FirstName; agent.PhoneNumber = lvm.AgentModel.PhoneNumber; agent.ValueDate = DateTime.Now.ToString("yyyy:mm:dd"); agent.ValueDate = DateTime.Now.ToString("HH:mm:ss"); lvm.AccountsModel.isVissibles = 1; user.isVissibles = 1; lvm.AgentModel.DateCreated = DateTime.Now; agent.DateCreated = DateTime.Now; db.Users.Add(user); db.SaveChanges(); db.Agents.Add(agent); db.SaveChanges(); TempData["Message"] = "Agent Succesfully Created"; return(View("Index")); } else { TempData["Message"] = "Password and confirm password must match"; return(View("Index")); } } return(View("Index")); } catch (Exception ex) { WebLog.Log(ex.Message.ToString()); return(null); } }