예제 #1
0
        public IActionResult UserInfo(string userId)
        {
            var user   = _user.GetById(userId);
            var topics = _topic.TList(a => a.UserId == userId).OrderByDescending(a => a.AddTime).ToList();
            var replys = _reply.TList(a => a.UserId == userId).OrderByDescending(a => a.AddTime).ToList();

            ViewBag.TopicCount = topics.Count;
            ViewBag.ReplyCount = replys.Count;
            ViewBag.User       = user;
            ViewBag.Topics     = topics;
            ViewBag.Replys     = replys;
            return(View());
        }
예제 #2
0
        public IActionResult Index(string id)
        {
            var topic = _topic.GetById(id);

            if (topic == null)
            {
                return(Redirect("/"));
            }
            var replys = _reply.TList(a => a.TopicId == id).OrderBy(a => a.AddTime).ToList();

            topic.ViewCount += 1;
            _topic.Update(topic);
            var topicRecord  = _topicRecord.TList(a => a.TopicId == id);
            var followRecord = _followRecord.TList(a => a.FollowUserId == topic.UserId);
            var userId       = UserManager.GetUserId(User);

            if (!string.IsNullOrEmpty(userId))
            {
                topicRecord  = topicRecord.Where(a => a.UserId == userId);
                followRecord = followRecord.Where(a => a.UserId == userId);
            }
            if (topicRecord.Count() <= 0)
            {
                ViewBag.IsTopicRecord = 0;
            }
            else
            {
                ViewBag.IsTopicRecord = 1;
            }
            if (followRecord.Count() <= 0)
            {
                ViewBag.IsFollowRecord = 0;
            }
            else
            {
                ViewBag.IsFollowRecord = 1;
            }
            ViewBag.Replys = replys;
            return(View(topic));
        }