/// <summary> /// Complete Registration for the user /// </summary> /// <returns>IResult the result of whole registration process</returns> public IResult RegisterUser() { string message = ""; string email = registrationRequest.Email; string fname = registrationRequest.Firstname; string lname = registrationRequest.Lastname; DateTime dob = registrationRequest.Dob; string password = registrationRequest.Password; // Generate salt and hash password Hasher hasher = new Hasher(algorithm); HashObject hash = hasher.GenerateSaltedHash(password); string hashedPw = hash.HashedValue; string salt = hash.Salt; Account newAccount = new Account(email, hashedPw, salt); ICreateAccountDAO newAccountDAO = new SqlCreateAccountDAO(Environment.GetEnvironmentVariable("sqlConnectionAccount", EnvironmentVariableTarget.User)); ICreateAccountDAO newMappingDAO = new SqlCreateAccountDAO(Environment.GetEnvironmentVariable("sqlConnectionMapping", EnvironmentVariableTarget.User)); IMapperDAO mapperDAO = new SqlMapperDAO(Environment.GetEnvironmentVariable("sqlConnectionMapping", EnvironmentVariableTarget.User)); ICreateAccountDAO newUserDAO = new SqlCreateAccountDAO(Environment.GetEnvironmentVariable("sqlConnectionSystem", EnvironmentVariableTarget.User)); CreateAccountDAOs daos = new CreateAccountDAOs(newAccountDAO, newMappingDAO, newUserDAO, mapperDAO); ICreateAccountService cas = new SqlCreateAccountService(newAccount, daos); IResult checkResult = cas.Create(); message = message + checkResult.Message; bool ifSuccess = checkResult.IsSuccess; if (ifSuccess) { int sysID = mapperDAO.GetSysID(email); if (sysID != -1) { ISqlDAO DAO = new SqlDAO(Environment.GetEnvironmentVariable("sqlConnectionSystem", EnvironmentVariableTarget.User)); User newUser = new User(sysID, email, fname, lname, "Enable", dob, "male"); UpdateAccountSqlService updateAccount = new UpdateAccountSqlService(newUser, DAO); checkResult = updateAccount.Update(); message = message + checkResult.Message; ifSuccess = checkResult.IsSuccess; } else { ifSuccess = false; message = message + "failed to Retrieve sysID"; } } return(new CheckResult(message, ifSuccess)); }
public UserManagementManager() { var sqlDao = new SqlDAO(Environment.GetEnvironmentVariable("sqlConnectionSystem", EnvironmentVariableTarget.User)); var createAccountDAO = new SqlCreateAccountDAO(Environment.GetEnvironmentVariable("sqlConnectionAccount", EnvironmentVariableTarget.User)); var newMappingDAO = new SqlCreateAccountDAO(Environment.GetEnvironmentVariable("sqlConnectionMapping", EnvironmentVariableTarget.User)); var newUserDAO = new SqlCreateAccountDAO(Environment.GetEnvironmentVariable("sqlConnectionSystem", EnvironmentVariableTarget.User)); var mapperDAO = new SqlMapperDAO(Environment.GetEnvironmentVariable("sqlConnectionMapping", EnvironmentVariableTarget.User)); var bunchedDaos = new CreateAccountDAOs(createAccountDAO, newMappingDAO, newUserDAO, mapperDAO); _updatePermissionService = new PermissionUpdateSqlService(new SqlDAO(Environment.GetEnvironmentVariable("sqlConnectionSystem", EnvironmentVariableTarget.User)), new SqlMapperDAO(Environment.GetEnvironmentVariable("sqlConnectionMapping", EnvironmentVariableTarget.User))); _updateAccountService = new UpdateAccountSqlService(new SqlDAO(Environment.GetEnvironmentVariable("sqlConnectionSystem", EnvironmentVariableTarget.User))); _createAccountService = new SqlCreateAccountService(bunchedDaos); _deleteAccountService = new DeleteAccountSQLService(new SqlDAO(Environment.GetEnvironmentVariable("sqlConnectionSystem", EnvironmentVariableTarget.User)), new SqlDAO(Environment.GetEnvironmentVariable("sqlConnectionMapping", EnvironmentVariableTarget.User)), new SqlDAO(Environment.GetEnvironmentVariable("sqlConnectionAccount", EnvironmentVariableTarget.User))); _authNService = new AuthenticationService(new GetUserDao(Environment.GetEnvironmentVariable("sqlConnectionSystem", EnvironmentVariableTarget.User))); _authService = new JWTService(); }