Ejemplo n.º 1
0
        public ActionResult EditPage(long?pageId, long?ownerId, long?questionId)
        {
            if (UserContext.CurrentUser == null)
            {
                return(Redirect(SiteUrls.Instance().Login(true)));
            }

            if (!pageId.HasValue)
            {
                pageId = 0;
            }

            //声明必要的对象
            WikiPage          page          = null;
            WikiPageEditModel pageEditModel = null;

            //输入的wikiId是否有效
            if (pageId.HasValue && pageId.Value > 0)//编辑词条
            {
                page = wikiService.Get(pageId.Value);
                if (page == null)
                {
                    return(HttpNotFound());
                }
            }
            int ModuleSpeechCategoryId = Convert.ToInt32(ConfigurationManager.AppSettings["HaierSpeechModelFolderId"]);
            //百科分类
            IEnumerable <Category> siteCategories = categoryService.GetOwnerCategories(0, TenantTypeIds.Instance().WikiPage());

            ViewData["ownerCategories"] = siteCategories;

            if (pageId.HasValue && pageId.Value > 0)//编辑词条
            {
                pageResourceManager.InsertTitlePart("编辑词条");
                page          = wikiService.Get(pageId.Value);
                pageEditModel = page.AsEditModel();
            }
            else//创建词条
            {
                pageResourceManager.InsertTitlePart("新建词条");
                pageEditModel = new WikiPageEditModel();
                if (ownerId.HasValue)
                {
                    pageEditModel.OwnerId = ownerId.Value;
                }
                if (questionId.HasValue && questionId.Value > 0)
                {
                    string title = string.Empty;
                    string body  = string.Empty;
                    wikiService.GetAskTitleAndBody(questionId.Value, out title, out body);
                    pageEditModel.Title = title;
                    pageEditModel.Body  = body;
                }
            }

            return(View(pageEditModel));
        }