Exemple #1
0
        private string loadArticle(string articleId, string parentDirId
                                   , ref articlesViewModel viewModel)
        {
            string ret = "";
            // load directories
            tblArticle tbart  = new tblArticle();
            article    parent = null;

            viewModel.subjects = new List <article>();
            article art = null;

            if (!string.IsNullOrWhiteSpace(articleId))
            {
                art = tbart.GetArticleById(articleId);
                if (art != null)
                {
                    viewModel.articleTitle       = art.articleTitle;
                    viewModel.articleType        = art.articleType;
                    viewModel.articleHtmlContent = art.articleHtmlContent;
                    if (string.IsNullOrWhiteSpace(parentDirId))
                    {
                        parentDirId = art.belongToArticleDirId.ToString();
                    }
                }
            }
            if (art == null)
            {
                viewModel.articleTitle       = "";
                viewModel.articleType        = "";
                viewModel.articleHtmlContent = "";
            }
            if (!string.IsNullOrWhiteSpace(parentDirId))
            {
                parent = tbart.GetArticleById(parentDirId);
            }
            if (parent == null)
            {
                viewModel.parentDirId    = "";
                viewModel.parentDirTitle = "";
            }
            else
            {
                viewModel.parentDirId       = parent.articleId.ToString();
                viewModel.parentDirTitle    = parent.articleTitle;
                parent.belongToArticleDirId = parent.articleId;
                viewModel.subjects.Add(parent);
            }
            viewModel.directories = tbart.directoriesByParentArticleId(parentDirId);
            // load subjects
            viewModel.subjects.AddRange(tbart.subjectsByParentArticleId(parentDirId));
            // the article of the current directory, should be listed at the top of the subject list
            // and view its content when click on it
            return(ret);
        }
Exemple #2
0
        private string loadArticle(string articleId, string parentDirId
                                   , ref articlesViewModel viewModel)
        {
            string ret = "";
            // load directories
            tblArticle tbart  = new tblArticle();
            Article    parent = null;

            if (!string.IsNullOrWhiteSpace(articleId))
            {
                Article art = tbart.GetArticleById(articleId);
                viewModel.articleTitle       = art.ArticleTitle;
                viewModel.articleHtmlContent = art.ArticleHtmlContent;
                parentDirId = art.BelongToArticleDirId.ToString();
            }
            else
            {
                viewModel.articleTitle = "";
            }
            if (!string.IsNullOrWhiteSpace(parentDirId))
            {
                parent = tbart.GetArticleById(parentDirId);
            }
            if (parent == null)
            {
                viewModel.parentDirId    = "";
                viewModel.parentDirTitle = "";
            }
            else
            {
                viewModel.parentDirId    = parent.ArticleId.ToString();
                viewModel.parentDirTitle = parent.ArticleTitle;
            }
            viewModel.directories = tbart.directoriesByParentArticleId(parentDirId);
            // load subjects
            viewModel.subjects = tbart.subjectsByParentArticleId(parentDirId);
            return(ret);
        }