Exemple #1
0
        public async Task <IActionResult> GetAsync([FromRoute] string WikiURL, bool html = true)
        {
            try
            {
                var repoWiki = await((html) ? _wikiRepository.GetWikiWithHTMLAsync(WikiURL) : _wikiRepository.GetWikiWithMDAsync(WikiURL));

                Wiki wiki = new Wiki()
                {
                    Url          = repoWiki.Url,
                    PageName     = repoWiki.PageName ?? WikiURL,
                    Description  = (html) ? repoWiki.HtmlDescription : repoWiki.MdDescription,
                    PopularPages = (from repoPage in await _repository.GetPopularPagesAsync(WikiURL, 5)
                                    select new Page()
                    {
                        Content = (html) ? repoPage.HtmlContent : repoPage.MdContent,
                        Details = repoPage.Details,
                        Contents = repoPage.Contents,
                        Url = repoPage.Url,
                        PageName = repoPage.PageName ?? repoPage.Url
                    })
                };

                return(Ok(wiki));
            }
            catch (Exception e)
            {
                _logger.LogError(e.Message);
                return(NotFound());
            }
        }