示例#1
0
        public virtual async Task <ArticleViewModel> GetArticleById(int articleId)
        {
            var vm = new ArticleViewModel();

            vm.Article = await FindByIdAsync(articleId);

            vm.Tags         = GetTagsByArticleId(articleId);
            vm.CategoryList = await _articleCategoryService.GetByCriteria(c => c.IsActive).ToListAsync();

            //vm.AllOfTags = _tagRepository.GetAll().Where(c => c.IsActive == true).ToList();
            return(vm);
        }
示例#2
0
        public async Task <IActionResult> Create()
        {
            var tags = await _tagService.GetByCriteria(c => c.IsActive == true).ToListAsync();

            for (int i = 0; i < tags.Count; i++)
            {
                tags[i].IsActive = false;
            }
            var articleViewModel = new ArticleViewModel()
            {
                Article      = new Article(),
                AllTags      = tags,
                CategoryList = await _articleCategoryService.GetByCriteria(c => c.IsActive).ToListAsync()
            };

            //StringLengthAttribute strLenAttr = typeof(Article).GetProperty("Summary")?.GetCustomAttributes(typeof(StringLengthAttribute), false).Cast<StringLengthAttribute>().SingleOrDefault();
            //if (strLenAttr != null)
            //{
            //    int maxLen = strLenAttr.MaximumLength;
            //}
            return(View(articleViewModel));
        }
        public async Task <IViewComponentResult> InvokeAsync()
        {
            List <ArticleCategory> catList = await _articleCategoryService.GetByCriteria(c => c.IsActive).ToListAsync();

            return(View(catList));
        }
        // GET: ArticleCategory
        public async Task <ActionResult> Index()
        {
            var list = await _articleCategoryService.GetByCriteria().ToListAsync();

            return(View(list));
        }