// GET: Store
        public ActionResult Index(string categoryId)
        {
            User user = (User)Session["User"];

            List <Item> products = new List <Item>();

            //only take 10 products...
            if (user != null)
            {
                string name   = user.Email;
                int    userId = user.UserId;
                products = RecommendationHelper.GetViaFunction("assoc", userId, 12);
            }
            else
            {
                products = RecommendationHelper.GetViaFunction("top", 0, 12);
            }

            var randomVm = Mapper.Map <List <Models.ProductListModel> >(RecommendationHelper.GetViaFunction("random", 0, 12));

            var productsVm = Mapper.Map <List <Models.ProductListModel> >(products);

            // Retrieve category listing:
            var categoriesVm = Mapper.Map <List <Models.CategoryModel> >(categories.ToList());

            var vm = new Models.StoreIndexModel
            {
                RandomProducts = randomVm,
                Products       = productsVm,
                Categories     = categoriesVm
            };

            return(View(vm));
        }
Example #2
0
        public ActionResult Index()
        {
            var vm = new HomeModel();

            vm.RecommendProductsTop = RecommendationHelper.GetViaFunction("top", 0, 50);

            return(View(vm));
        }
Example #3
0
        public ActionResult Index()
        {
            var vm = new HomeModel();

            Contoso.Apps.Movies.Data.Models.User user = (Contoso.Apps.Movies.Data.Models.User)Session["User"];

            vm.RecommendProductsTop = RecommendationHelper.GetViaFunction("top", 0, 10);

            if (user != null)
            {
                vm.RecommendProductsBought = RecommendationHelper.GetViaFunction("assoc", user.UserId, 10);
                vm.RecommendProductsLiked  = RecommendationHelper.GetViaFunction("collab", user.UserId, 10);
            }

            return(View(vm));
        }
        public IHttpActionResult Recommend(string algo, int count)
        {
            List <Item> products = new List <Item>();

            if (HttpContext.Current.Session != null && HttpContext.Current.Session["User"] != null)
            {
                Contoso.Apps.Movies.Data.Models.User user = (Contoso.Apps.Movies.Data.Models.User)HttpContext.Current.Session["User"];
                string name   = user.Email;
                int    userId = user.UserId;

                products = RecommendationHelper.GetViaFunction(algo, userId, count);
            }
            else
            {
                products = RecommendationHelper.GetViaFunction(algo, 0, count);
            }

            return(Json(products));
        }
        // GET: Store/Details/5
        public async Task <ActionResult> Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            Item product = await SqlDbHelper.GetItem(id);

            if (product == null)
            {
                return(HttpNotFound());
            }

            var productVm = Mapper.Map <Models.ProductModel>(product);

            //Get the simliar product to this item...
            var similarProducts   = RecommendationHelper.GetViaFunction("content", 0, id.Value);
            var similarProductsVm = Mapper.Map <List <Models.ProductListModel> >(similarProducts);

            // Find related products, based on the category
            var relatedProducts   = items.Where(p => p.CategoryId == product.CategoryId && p.ItemId != product.ItemId).Take(10).ToList();
            var relatedProductsVm = Mapper.Map <List <Models.ProductListModel> >(relatedProducts);

            // Retrieve category listing
            var categoriesVm = Mapper.Map <List <Models.CategoryModel> >(categories);

            // Retrieve "new products" as a list of three random products not equal to the displayed one
            var newProducts = items.Where(p => p.ItemId != product.ItemId).Take(50).ToList().Shuffle().Take(3);

            var newProductsVm = Mapper.Map <List <Models.ProductListModel> >(newProducts);

            var vm = new Models.StoreDetailsModel
            {
                Product         = productVm,
                RelatedProducts = relatedProductsVm,
                SimilarProducts = similarProductsVm,
                NewProducts     = newProductsVm,
                Categories      = categoriesVm
            };

            return(View(vm));
        }
        public IHttpActionResult SimilarUsers(string algo)
        {
            List <Data.Models.User> users = new List <Data.Models.User>();

            Contoso.Apps.Movies.Data.Models.User user = (Contoso.Apps.Movies.Data.Models.User)HttpContext.Current.Session["User"];
            string name   = user.Email;
            int    userId = user.UserId;

            switch (algo)
            {
            case "jaccard":
                users = RecommendationHelper.GetViaFunction(userId);
                break;

            case "pearson":
                users = RecommendationHelper.GetViaFunction(userId);
                break;
            }

            return(Json(users));
        }
Example #7
0
        // GET: Store
        public ActionResult Index(string categoryId)
        {
            User user = (User)Session["User"];

            List <Item> products = RecommendationHelper.GetViaFunction("top", 0, 100);

            var randomVm = Mapper.Map <List <Models.ProductListModel> >(RecommendationHelper.GetViaFunction("random", 0, 10));

            var productsVm = Mapper.Map <List <Models.ProductListModel> >(products);

            // Retrieve category listing:
            var categoriesVm = Mapper.Map <List <Models.CategoryModel> >(categories.ToList());

            var vm = new Models.StoreIndexModel
            {
                RandomProducts = randomVm,
                Products       = productsVm,
                Categories     = categoriesVm
            };

            return(View(vm));
        }