public async Task <bool> Log(string user_id, string item_id, string event_type, string session_id) { Contoso.Apps.Movies.Data.Models.User user = (Contoso.Apps.Movies.Data.Models.User)Session["User"]; if (user != null) { string name = user.Email; int userId = user.UserId; Item i = await DbHelper.GetItem(int.Parse(item_id)); if (i != null) { CollectorLog log = new CollectorLog(); log.id = Guid.NewGuid().ToString(); log.UserId = userId.ToString(); log.ContentId = i.ImdbId; log.ItemId = item_id; log.Event = event_type; log.SessionId = session_id; log.Created = DateTime.Now; //add to cosmos db var container = client.GetContainer(databaseId, "events"); await container.CreateItemAsync(log); } } return(true); }
// GET: Store public ActionResult Index(string categoryId) { Contoso.Apps.Movies.Data.Models.User user = (Contoso.Apps.Movies.Data.Models.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)); }
public ActionResult Index() { var vm = new HomeModel(); Contoso.Apps.Movies.Data.Models.User user = (Contoso.Apps.Movies.Data.Models.User)Session["User"]; //TODO #1 vm.RecommendProductsTop = new List <Item>(); //TODO #3 vm.RecommendProductsLiked = new List <Item>(); return(View(vm)); }
public IHttpActionResult Logs() { List <CollectorLog> logs = new List <CollectorLog>(); Contoso.Apps.Movies.Data.Models.User user = (Contoso.Apps.Movies.Data.Models.User)HttpContext.Current.Session["User"]; if (user != null) { string name = user.Email; int userId = user.UserId; logs = DbHelper.GetUserLogs(userId, 100); } return(Json(logs)); }
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)); }
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)); }