/// <summary> /// Validates list of user data /// </summary> /// <param name="userDataList">User data list to be validated</param> /// <param name="userId">User id to whom user data belong</param> public void ValidateUserData( IEnumerable <UserDataEntity> userDataList, int?userId = null ) { if (userDataList == null) { return; } var flatUserDataList = m_userDataStructureConvertor.GetFlatUserDataList(userDataList); var validationOptions = new ValidationOptions { UserId = userId, MinLevelOfAssuranceToValidateAgainst = LevelsOfAssurance.UserDataLoaToBeGreaterThanForUniqueValidation, }; foreach (var userData in flatUserDataList) { var validatorTypes = GetValidatorTypes(userData.UserDataType.DataTypeValue); foreach (var validatorType in validatorTypes) { m_dataValidatorsDic[validatorType].Validate(userData, validationOptions); } } }
private void UpdateUserData( DateTime now, UserEntity userEntity, IList <UserDataLoAModel> userData, UserAction action, string externalProviderName = null ) { var currentUserDataSet = m_userDataVersioningProxy.FindUserDataWithTreeStructure(userEntity.Id); var userDataDict = m_userDataStructureConvertor.GetFlatUserDataList(currentUserDataSet) ?.ToDictionary(x => x.UserDataType.DataTypeValue); var userDataTypesDict = m_userDataTypeRepository.GetAllUserDataTypes().ToDictionary(x => x.DataTypeValue); var userDataToUpdate = new List <UserDataEntity>(); HydrateUserData(now, userEntity, userData, userDataToUpdate, userDataDict, userDataTypesDict, externalProviderName ); switch (action) { case UserAction.Create: m_userDataVersioningProxy.CreateUserData(userDataToUpdate); break; case UserAction.Update: m_userDataVersioningProxy.UpdateUserData(userDataToUpdate); break; default: throw new ArgumentOutOfRangeException(nameof(action), action, null); } }