Beispiel #1
0
        private static void RatingBlock(float existingRating, VariableCollection variables, Template template, ItemKey itemKey)
        {
            int starsRating = 0;
            string one, two, three, four, five;
            string one_class, two_class, three_class, four_class, five_class;
            one = two = three = four = five = RANK_SHADOW;
            one_class = two_class = three_class = four_class = five_class = "rank-off";

            starsRating = (int)Math.Round(existingRating);

            switch (starsRating)
            {
                case 5:
                    one = two = three = four = five = RANK_RATING;
                    one_class = two_class = three_class = four_class = five_class = "rank-on";
                    break;
                case 4:
                    one = two = three = four = RANK_RATING;
                    one_class = two_class = three_class = four_class = "rank-on";
                    break;
                case 3:
                    one = two = three = RANK_RATING;
                    one_class = two_class = three_class = "rank-on";
                    break;
                case 2:
                    one = two = RANK_RATING;
                    one_class = two_class = "rank-on";
                    break;
                case 1:
                    one = RANK_RATING;
                    one_class = "rank-on";
                    break;
            }

            Dictionary<string, string> loopVars = new Dictionary<string, string>(20, StringComparer.Ordinal);

            loopVars.Add("STAR_ONE", one);
            loopVars.Add("STAR_TWO", two);
            loopVars.Add("STAR_THREE", three);
            loopVars.Add("STAR_FOUR", four);
            loopVars.Add("STAR_FIVE", five);

            loopVars.Add("STAR_ONE_CLASS", one_class);
            loopVars.Add("STAR_TWO_CLASS", two_class);
            loopVars.Add("STAR_THREE_CLASS", three_class);
            loopVars.Add("STAR_FOUR_CLASS", four_class);
            loopVars.Add("STAR_FIVE_CLASS", five_class);

            loopVars.Add("U_RATE_ONE_STAR", string.Format("/api/rate?rating=1&amp;item={0}&amp;type={1}", itemKey.Id, itemKey.TypeId));
            loopVars.Add("U_RATE_TWO_STAR", string.Format("/api/rate?rating=2&amp;item={0}&amp;type={1}", itemKey.Id, itemKey.TypeId));
            loopVars.Add("U_RATE_THREE_STAR", string.Format("/api/rate?rating=3&amp;item={0}&amp;type={1}", itemKey.Id, itemKey.TypeId));
            loopVars.Add("U_RATE_FOUR_STAR", string.Format("/api/rate?rating=4&amp;item={0}&amp;type={1}", itemKey.Id, itemKey.TypeId));
            loopVars.Add("U_RATE_FIVE_STAR", string.Format("/api/rate?rating=5&amp;item={0}&amp;type={1}", itemKey.Id, itemKey.TypeId));

            loopVars.Add("RATE_RATING", string.Format("{0:0.0}", existingRating));
            loopVars.Add("RATE_ACTIVE", RANK_ACTIVE);
            loopVars.Add("RATE_TYPE", itemKey.TypeId.ToString());
            loopVars.Add("S_RATEBAR", "TRUE");

            if (template != null)
            {
                template.ParseVariables(loopVars);
            }
            else
            {
                variables.ParseVariables(loopVars);
            }
        }