コード例 #1
0
        /// <summary>
        /// 首页
        /// </summary>
        /// <returns></returns>
        public IActionResult Index()
        {
            ViewModels.HomeViewModel viewModel = new ViewModels.HomeViewModel();
            int pageSize = 5;
            //加载帖子数据
            PostsRepository repository = new PostsRepository();
            var             query      = repository.GetPostsPageList();

            viewModel.PostsDatas = query.Where(m => m.IsShow == true).Take(pageSize).ToList();
            //加载文档主题数据
            DocsRepository docsRepository = new DocsRepository();

            viewModel.DocsDatas = docsRepository.GetDocsByPage().OrderByDescending(m => m.DocsId).Where(m => m.IsShow == true).Take(pageSize).ToList();
            return(View(viewModel));
        }
コード例 #2
0
        /// <summary>
        /// 文档首页
        /// </summary>
        /// <returns></returns>
        public IActionResult Index()
        {
            ViewModels.DocsViewModel model = new ViewModels.DocsViewModel();
            //查询帖子数据
            int            pageIndex  = Framework.Core.Transform.GetInt(Request.Query["p"], 1);
            int            pageSize   = 10;
            DocsRepository repository = new DocsRepository();
            var            query      = repository.GetDocsThemeList();

            model.ListData   = query.Where(q => q.IsShow == true).Skip(pageSize * (pageIndex - 1)).Take(pageSize).ToList();
            model.TotalCount = query.Where(q => q.IsShow == true).Count();


            return(View(model));
        }
コード例 #3
0
ファイル: MyDocsController.cs プロジェクト: luochunjiu/lcj
        public IActionResult EditTheme(int id)
        {
            ViewModels.DocsThemeEditViewModel model = new ViewModels.DocsThemeEditViewModel();
            int userId = Framework.Core.Transform.GetInt(HttpContext.Session.GetString("UserId"), 0);
            //加载帖子数据
            DocsRepository repository = new DocsRepository();

            model.DocsThemeData = repository.GetDocsThemeById(id, userId);
            if (model.DocsThemeData != null)
            {
                return(View(model));
            }
            return(new ContentResult()
            {
                Content = "您的请求未得到授权!",
                StatusCode = 401
            });
        }
コード例 #4
0
        public IActionResult Read(int id, int docsid = 0)
        {
            DocsRepository repository = new DocsRepository();

            ViewModels.DocsReadViewModel model = new ViewModels.DocsReadViewModel();
            model.DocsId  = docsid;
            model.ThemeId = id;
            if (docsid == 0)
            {
                model.DocsThemeData = repository.GetDocsThemeById(id);
            }
            else
            {
                model.DocsData = repository.GetDocsById(docsid);
            }
            model.ItemsListData = repository.GetDocsListById(id);
            return(View(model));
        }