コード例 #1
0
        /// <summary>
        /// 个人主页
        /// </summary>
        /// <returns></returns>
        public ActionResult person(string userid)
        {
            if (userid == null)
            {
                return(Redirect("/home"));
            }
            //用户自己的案件的话获取用户的其他私人案件
            if (User.Identity.IsAuthenticated)
            {
                UserInfo     dbinfo  = new UserInfo();
                CaseInfoList dbcase  = new CaseInfoList();
                var          userLog = dbinfo.GetUserById(userid);
                if (userLog != null)
                {
                    if (User.Identity.Name == userLog.UserName)
                    {
                        var caselist = dbcase.GetUserCase(userLog.UserName);
                        ViewBag.UserCase = caselist;
                    }
                }
            }
            UserInfo dbuser = new UserInfo();
            var      user   = dbuser.userPage(userid);

            return(View(user));
        }
コード例 #2
0
        public ActionResult searchCase(string searchTxt)
        {
            if (HttpContext.User.Identity.IsAuthenticated)
            {
                //登陆后返回给用户相应的信息
                CaseInfoList dbUserCase = new CaseInfoList();
                var          usercase   = dbUserCase.GetUserCase(HttpContext.User.Identity.Name);
                ViewBag.UserCase = usercase;
            }
            CaseInfoList dbcase   = new CaseInfoList();
            var          caselist = dbcase.HomeCaseList().Where(t => t.casetitle.Contains(searchTxt) || t.casecontent.Contains(searchTxt)).ToList();

            return(View("Index", caselist));
        }
コード例 #3
0
        /// <summary>
        /// 首页话题
        /// </summary>
        /// <returns></returns>
        public ActionResult Index()
        {
            //判断用户是都已经登录
            if (HttpContext.User.Identity.IsAuthenticated)
            {
                //登陆后返回给用户相应的信息
                CaseInfoList dbUserCase = new CaseInfoList();
                var          usercase   = dbUserCase.GetUserCase(HttpContext.User.Identity.Name);
                ViewBag.UserCase = usercase;
            }
            //公共信息
            CaseInfoList dbcase   = new CaseInfoList();
            var          caselist = dbcase.HomeCaseList();

            //var temp = caselist.FirstOrDefault().commentlist.Count();
            return(View(caselist));
        }