Example #1
0
        private IList <ScoreStore> CalculateScore(IList <Store> stores, EnumSkrType type, User user)
        {
            ScoreRatio scoreRatio = GetScoreRatio(type);

            return(stores.Select(s => CalculateScore(s, scoreRatio, user))
                   .Where(s => s.FinalScore > 0)
                   .OrderByDescending(s => s.FinalScore)
                   .ToList());
        }
Example #2
0
        private ScoreRatio GetScoreRatio(EnumSkrType type)
        {
            ScoreRatio result = new ScoreRatio();

            switch (type)
            {
            case EnumSkrType.Random:
                result.CurrentStoreScoreRatio           = 1;
                result.CurrentStoreScoreWithOthersRatio = 5;
                result.DistanceScoreRatio     = 3;
                result.TenDayNoEatScoreRatio  = 5;
                result.PriceRatio             = 2;
                result.NotAlwaysEatScoreRatio = 4;
                break;

            case EnumSkrType.NotEatenYetRandom:
                result.CurrentStoreScoreRatio           = 1;
                result.CurrentStoreScoreWithOthersRatio = 5;
                result.DistanceScoreRatio     = 3;
                result.TenDayNoEatScoreRatio  = 5;
                result.PriceRatio             = 2;
                result.NotAlwaysEatScoreRatio = 5;
                break;

            case EnumSkrType.SimpleFilter:
                result.CurrentStoreScoreRatio           = 5;
                result.CurrentStoreScoreWithOthersRatio = 1;
                result.DistanceScoreRatio     = 3;
                result.TenDayNoEatScoreRatio  = 3;
                result.PriceRatio             = 2;
                result.NotAlwaysEatScoreRatio = 1;
                break;

            case EnumSkrType.Favorite:
                result.CurrentStoreScoreRatio           = 5;
                result.CurrentStoreScoreWithOthersRatio = 1;
                result.DistanceScoreRatio     = 1;
                result.TenDayNoEatScoreRatio  = 1;
                result.PriceRatio             = 1;
                result.NotAlwaysEatScoreRatio = 1;
                break;

            default:
                result.CurrentStoreScoreRatio           = 1;
                result.CurrentStoreScoreWithOthersRatio = 1;
                result.DistanceScoreRatio     = 1;
                result.TenDayNoEatScoreRatio  = 1;
                result.PriceRatio             = 1;
                result.NotAlwaysEatScoreRatio = 1;
                break;
            }

            return(result);
        }
Example #3
0
        private ScoreStore CalculateScore(Store store, ScoreRatio scoreRatio, User user)
        {
            ScoreStore scoreStore        = new ScoreStore(store);
            int        eatInTenDayRecord = 0;

            double currentStoreScore = CalculateFirstScore(store, scoreRatio.CurrentStoreScoreRatio);

            double currentStoreScoreWithOthers = CalculateSecondScore(store, scoreRatio.CurrentStoreScoreWithOthersRatio);

            double distanceScore = CalculateThirdScore(store, scoreRatio.DistanceScoreRatio);

            IDictionary <string, double> fourthResult = CalculateFourthScore(store, scoreRatio.TenDayNoEatScoreRatio, user);
            double tenDayNoEatScore = fourthResult["tenDayNoEatScore"];

            eatInTenDayRecord = Convert.ToInt32(fourthResult["eatInTenDayRecord"]);

            double priceScore = CalculateFifthScore(store, scoreRatio.PriceRatio);

            double notAlwaysEatScore = CalculateSixthScore(store, scoreRatio.NotAlwaysEatScoreRatio, eatInTenDayRecord);

            scoreStore.FinalScore = currentStoreScore + currentStoreScoreWithOthers + distanceScore + tenDayNoEatScore + priceScore + notAlwaysEatScore;

            return(scoreStore);
        }