示例#1
0
        public ActionResult Show(PagePath pagePath, string id)
        {
            var loadContext = _pageService.Load(pagePath);
            if (loadContext == null)
            {
                return this.RedirectToWikiPage(pagePath);
            }

            var tocBuilder = new TableOfContentsBuilder();
            tocBuilder.Compile(loadContext.Body);

            var tree = _pageTreeRepository.Get(loadContext.Page.Id);
            var model = new ShowViewModel
                            {
                                Body = loadContext.Body,
                                PagePath = pagePath,
                                Title = loadContext.Page.Title,
                                UpdatedAt = loadContext.Page.UpdatedAt,
                                UserName = loadContext.Page.UpdatedBy.DisplayName,
                                BackLinks = loadContext.Page.BackReferences.ToList(),
                                TableOfContents = tocBuilder.GenerateList(),
                                Path = tree.CreateLinksForPath(Url.WikiRoot())
                            };

            return View("Show", model);
        }
 //展示文本文档
 public async Task<ActionResult> Show(string ResourceId)
 {
     ViewBag.Title = "文档";
     ShowViewModel viewModel = new ShowViewModel();
     viewModel.Resource = await ResourceService.getResourceById(ResourceId);
     Session["CourseId"] = viewModel.Resource.Course.CourseId;
     viewModel.Group = await ResourceGroupService.GetResourceGroupByGroupId(viewModel.Resource.ResourceGroup.GroupId);
     MarkModel Lovemodel = new MarkModel();
     if (Session["LoginUser"] != null)
     {
         Lovemodel.User = Session["LoginUser"] as UserModel;
         MarkModel Learnmodel = new MarkModel();
         Learnmodel.User = Session["LoginUser"] as UserModel;
         Learnmodel.MarkType = await MarkTypeService.getMarkTypeByTypeName("观看");
         Learnmodel.Resource = await ResourceService.getResourceById(ResourceId);
         if (!await MarkService.MarkIsExist(Learnmodel))
         {
             await MarkService.CreatLearned(Learnmodel);
         }
         Lovemodel.MarkType = await MarkTypeService.getMarkTypeByTypeName("收藏");
         Lovemodel.Resource = await ResourceService.getResourceById(ResourceId);
         if (await MarkService.MarkIsExist(Lovemodel))
         {
             viewModel.IsLove = true;
         }
         else
         {
             viewModel.IsLove = false;
         }
     }
     if (viewModel.Group.GroupName.ToString().Trim() != "不分组")
     {
         viewModel.GroupResourceList = await ResourceService.getResourceByGroup(viewModel.Group.GroupId);
     }
     else
     {
         viewModel.GroupResourceList = new List<ResourceModel>();
     }
     return View(viewModel);
 }