示例#1
0
        public async Task <IActionResult> Details(Guid?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            var weArticle = await _context.WeArticle.Where(p => p.Id == id).FirstOrDefaultAsync();

            if (weArticle == null)
            {
                return(NotFound());
            }
            var _Author = _userManager.FindByIdAsync(weArticle.AuthorUserId).GetAwaiter().GetResult();

            ViewData["CurrentUserId"] = _userManager.GetUserAsync(User)?.GetAwaiter().GetResult()?.Id ?? string.Empty;

            ViewData["AuthorUserId"]    = _Author.Id;
            ViewData["AuthorUserEmail"] = _Author.Email;

            _weEduHubArticleClassHelper.InitialWeArticleClassName(ref weArticle, weArticle.ClassId);

            ViewData["WeArticleFileContentType"] = _funFilesHelper.GetContentType(
                await _context.WeArticleFile.Where(p => p.Id == weArticle.WeArticleContentFileId).Select(p => p.Name).FirstOrDefaultAsync()
                );

            weArticle.SetName = await _context.WeArticleSet.Where(p => p.Id == weArticle.SetId).Select(p => p.Name).FirstOrDefaultAsync();

            return(View(weArticle));
        }
示例#2
0
        public async Task <IActionResult> GetContent(Guid ContentId)
        {
            var _WeArticle = await _context.WeArticle.Where(p => p.Id == ContentId).FirstOrDefaultAsync();

            var _User = _userManager.GetUserAsync(User).GetAwaiter().GetResult();

            if (_WeArticle != null)
            {
                ViewData["AuthorUserId"]    = _User?.Id ?? string.Empty;;
                ViewData["AuthorUserEmail"] = _User?.Email ?? string.Empty;

                _weEduHubArticleClassHelper.InitialWeArticleClassName(ref _WeArticle, _WeArticle.ClassId);

                ViewData["WeArticleFileContentType"] = _funFilesHelper.GetContentType(
                    await _context.WeArticleFile.Where(p => p.Id == _WeArticle.WeArticleContentFileId).Select(p => p.Name).FirstOrDefaultAsync()
                    );

                return(View("WeArticleDetails", _WeArticle));
            }
            return(NoContent());
        }