Ejemplo n.º 1
0
        public ActionResult Recommend()
        {
            List <int> recommendList = new List <int>();

            // 用户已经登录
            if (System.Web.HttpContext.Current.User.Identity.IsAuthenticated)
            {
                int userId = int.Parse(System.Web.HttpContext.Current.User.Identity.Name);
                //从推荐列表中查询
                if (RecommendedSystemHelper.GetRecommend(userId).Count > 0)
                {
                    recommendList = RecommendedSystemHelper.GetRecommend(userId).Take(6).ToList();
                }
                else
                {
                    recommendList = RecommendedSystemHelper.GetTop().Take(6).ToList();
                }

                //推荐访问率最高的
            }
            else // 用户未登录,推荐访问率最高的
            {
                recommendList = RecommendedSystemHelper.GetTop().Take(6).ToList();
            }
            return(View(recommendList));
            // return Json(recommendList,JsonRequestBehavior.AllowGet);
        }
Ejemplo n.º 2
0
        // GET api/Recommend/id
        public List <int> Get(int id)
        {
            List <int> recommendList = new List <int>();

            recommendList = RecommendedSystemHelper.GetRecommend(id).Take(6).ToList();
            // 用户已经登录
            //if (System.Web.HttpContext.Current.User.Identity.IsAuthenticated)
            //{
            //    int userId = int.Parse(System.Web.HttpContext.Current.User.Identity.Name);
            //    //从推荐列表中查询
            //    if (RecommendedSystemHelper.GetRecommend(userId).Count > 0)
            //    {
            //        recommendList = RecommendedSystemHelper.GetRecommend(userId).Take(6).ToList();
            //    }
            //    else
            //    {
            //        recommendList = RecommendedSystemHelper.GetTop().Take(6).ToList();
            //    }

            //    //推荐访问率最高的
            //}
            //else // 用户未登录,推荐访问率最高的
            //{
            //    recommendList = RecommendedSystemHelper.GetTop().Take(6).ToList();
            //}
            return(recommendList);
        }
Ejemplo n.º 3
0
        public ActionResult Login(LoginModel model, string returnUrl)
        {
            if (ModelState.IsValid && RecommendedSystemHelper.Login(model.UserName))
            {
                FormsAuthentication.SetAuthCookie(model.UserName, model.RememberMe);
                return(RedirectToLocal(returnUrl));
            }

            // If we got this far, something failed, redisplay form
            ModelState.AddModelError("", "The user name or password provided is incorrect.");
            return(View(model));
        }