예제 #1
0
        public IActionResult Document([FromRoute] int themeId, [FromRoute] int p = 1)
        {
            int accountId = HttpContext.Session.GetInt32("AccountId").GetValueOrDefault(0);

            Models.MyThemeDocumentViewModel viewModel = new Models.MyThemeDocumentViewModel();

            var docRepository = _unitOfWork.GetRepository <Entity.m_Docs>();

            viewModel.ListData = docRepository.Query()
                                 .Where(q => q.ThemeId == themeId && q.IsShow == true && q.AccountId == accountId)
                                 .OrderByDescending(q => q.DocsId)
                                 .Select(q => new Models.DocumentDataModel()
            {
                DocsId     = q.DocsId.Value,
                ShortTitle = q.ShortTitle,
                Title      = q.Title,
                ThemeId    = q.ThemeId.Value,
                IsShow     = q.IsShow.Value,
                AppendTime = q.AppendTime,
                PlusCount  = q.PlusCount,
                ReadCount  = q.ReadCount,
                AccountId  = q.AccountId
            })
                                 .OrderByDescending(q => q.DocsId)
                                 .Skip(10 * (p - 1))
                                 .Take(10)
                                 .ToList();
            viewModel.TotalCount = docRepository.Query().Where(q => q.ThemeId == themeId && q.IsShow == true && q.AccountId == accountId).Select(q => q.DocsId).Count();
            return(View(viewModel));
        }
예제 #2
0
        public IActionResult Document([FromRoute] int themeId, [FromRoute] int p = 1)
        {
            int accountId = HttpContext.Session.GetInt32("AccountId").GetValueOrDefault(0);

            Models.MyThemeDocumentViewModel viewModel = new Models.MyThemeDocumentViewModel();
            var apiResult = HttpCore.HttpGet($"/api/Docs/Theme/user/{accountId}/{themeId}/{p}");

            if (apiResult.Code == 0)
            {
                viewModel.ListData = JsonConvert.DeserializeObject <List <Models.DocumentDataModel> >(apiResult.Data.ToString());
            }
            return(View(viewModel));
        }