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()); }
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); }
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); }