Exemplo n.º 1
0
        public void FindAllPagerTest()
        {
            var list =
                _articleDbProxyRepository.FindAllPager(null, null, null, null, null, null, 1, int.MaxValue);

            Console.WriteLine(list.TotalCount);
        }
Exemplo n.º 2
0
        //[OutputCache(Duration = 5, VaryByParam = "pageIndex")]
        public ActionResult Articles(string domain, int?year, int?mouth, int?tag, int?articleTypeId, int?pageIndex)
        {
            var user      = UserQueryService.GetUserByDomain(domain);
            var userId    = user.ID;
            var result    = _articleQueryService.FindAllPager(userId, articleTypeId, tag, year, mouth, true, pageIndex ?? 1, PageSize);
            var viewModel = result.Select(CreateArticleViewModel).ToPagedList(pageIndex ?? 1, PageSize, result.TotalCount);

            ViewData["domain"] = HistoryUser.Domain;


            #region 如果未登录或者当前用户是当前访问用户 不进行访问信息记录
            if (!IsLogin)
            {
                return(View("Index", viewModel));
            }

            if (CurrentUser.UserId == HistoryUser.UserId)
            {
                return(View("Index", viewModel));
            }
            #endregion

            // 更新访问信息
            try
            {
                const int maxCount = 50;
                using (var transaction = UnitOfWork.Begin())
                {
                    _processor.Process <CreateUserTourLogCommand>(
                        new CreateUserTourLogCommand(CurrentUser.UserId, HistoryUser.UserId)
                    {
                        MaxTourUserCount = maxCount
                    });
                    transaction.Commit();
                }
            }
            catch (Exception ex)
            {
                // 记录日志
                LogServer.Error("更新阅读次数失败", ex.Message, HttpContext.Request.Path);
            }
            return(View("Index", viewModel));
        }