示例#1
0
        protected void productdetails_ItemCommand(object source, RepeaterCommandEventArgs e)
        {
            /// Gets the product ID,
            if (e.CommandName.Equals("Click"))
            {
                var itemIndex = e.Item.ItemIndex;
                var modelInfo = (string)ModelSelect.SelectedValue;
                modelId       = modelInfo.Split('_')[0];
                activeBuildId = Int64.Parse(modelInfo.Split('_')[1]);
                var recs = recommender.GetRecommendations(modelId, activeBuildId, products.ElementAt(itemIndex).productID, 5);

                recommendations.DataSource = recs.RecommendedItemSetInfo;
                recommendations.DataBind();
            }
        }
示例#2
0
        protected void productdetails_ItemCommand(object source, RepeaterCommandEventArgs e)
        {
            /// Gets the product ID,
            if (e.CommandName.Equals("Click"))
            {
                recs = new List <RecDetailsDisplay>();
                var itemIndex = e.Item.ItemIndex;
                var modelInfo = (string)ModelSelect.SelectedValue;

                if (modelInfo.Split('_')[1].Length > 0)
                {
                    modelId       = modelInfo.Split('_')[0];
                    activeBuildId = Int64.Parse(modelInfo.Split('_')[1]);
                    var recos = recommender.GetRecommendations(modelId, activeBuildId, products.ElementAt(itemIndex).productID, 5);

                    var rawRecs = recos.RecommendedItemSetInfo;
                    foreach (var rec in rawRecs)
                    {
                        var recId     = rec.Items.ElementAt(0).Id;
                        var recNum    = Int32.Parse(recId) - 1;
                        var prodToRec = new RecDetailsDisplay();
                        var prod      = products.ElementAt(recNum);
                        prodToRec.productID     = prod.productID;
                        prodToRec.title         = prod.title;
                        prodToRec.productArtUrl = prod.productArtUrl;
                        prodToRec.rating        = rec.Rating;
                        prodToRec.reasoning     = rec.Reasoning.ElementAt(0);
                        // var prod = products.Where(x => x.productID.Equals(recId)).Select(x => x);
                        recs.Add(prodToRec); //Since the product ID is at a zero-based index and the list is at a 1-based index
                    }


                    recommendations.DataSource = recs;
                    recommendations.DataBind();



                    recDisplay.Visible = true;
                }
            }
        }