Exemple #1
0
        private static int Score(IEnumerable <MatchingCriteria> criterias, IExactScoreConfiguration configuration)
        {
            var score = 0;

            foreach (var criteria in criterias)
            {
                if (criteria.Id == MatchingCriteriaEnum.FirstName)
                {
                    score += configuration.FirstNameExactScore /**criteria.Count*/;
                }
                if (criteria.Id == MatchingCriteriaEnum.LastName)
                {
                    score += configuration.LastNameExactScore /**criteria.Count*/;
                }
                if (criteria.Id == MatchingCriteriaEnum.Username)
                {
                    score += configuration.UsernameExactScore /**criteria.Count*/;
                }
                if (criteria.Id == MatchingCriteriaEnum.Address)
                {
                    score += configuration.AddressExactScore /**criteria.Count*/;
                }
                if (criteria.Id == MatchingCriteriaEnum.DateOfBirth)
                {
                    score += configuration.DateOfBirthExactScore /**criteria.Count*/;
                }
                if (criteria.Id == MatchingCriteriaEnum.Email)
                {
                    score += configuration.EmailAddressExactScore /**criteria.Count*/;
                }
                if (criteria.Id == MatchingCriteriaEnum.FullName)
                {
                    score += configuration.FullNameExactScore /**criteria.Count*/;
                }
                if (criteria.Id == MatchingCriteriaEnum.IPAddress)
                {
                    score += configuration.SignUpIpExactScore /**criteria.Count*/;
                }
                if (criteria.Id == MatchingCriteriaEnum.PhoneNumber)
                {
                    score += configuration.MobilePhoneExactScore /**criteria.Count*/;
                }
                if (criteria.Id == MatchingCriteriaEnum.Zipcode)
                {
                    score += configuration.ZipCodeExactScore /**criteria.Count*/;
                }
            }

            return(score);
        }
Exemple #2
0
        public int ScorePlayer(Guid basePlayerId, Guid secondaryPlayerId, IExactScoreConfiguration configuration = null)
        {
            var basePlayer      = _fraudRepository.Players.FirstOrDefault(x => x.Id == basePlayerId);
            var secondaryPlayer = _fraudRepository.Players.FirstOrDefault(x => x.Id == secondaryPlayerId);

            if (basePlayer == null || secondaryPlayer == null)
            {
                throw new RegoException("Can't find required player");
            }

            if (configuration == null)
            {
                configuration = _duplicateMechanismQueries
                                .GetConfigurations()
                                .FirstOrDefault(x => x.BrandId == basePlayer.BrandId);
            }

            if (configuration == null)
            {
                return(0);
            }

            var matching = _fraudRepository
                           .MatchingResults
                           .Include(o => o.MatchingCriterias)
                           .AsNoTracking()
                           .SingleOrDefault(x => (x.FirstPlayerId == basePlayerId && x.SecondPlayerId == secondaryPlayerId) ||
                                            (x.FirstPlayerId == secondaryPlayerId && x.SecondPlayerId == basePlayerId));

            if (matching == null)
            {
                return(0);
            }

            return(Score(matching.MatchingCriterias, configuration));
        }