Esempio n. 1
0
        public IActionResult Index()
        {
            ArticleTypeViewModel articleTypeViewModel = new ArticleTypeViewModel();

            articleTypeViewModel.BlogArticleTypes = _blogArticleType.GetAllList();
            return(View(articleTypeViewModel));
        }
        public IActionResult Index(long id)
        {
            var articleAction = ArticleActionEnum.Edit;
            var article       = _blogArticleService.GetArticle(id);

            if (article == null)
            {
                articleAction = ArticleActionEnum.Add;
                article       = new Service.Blog.Dtos.BlogArticleDto();
            }
            List <SelectListItem> v = new List <SelectListItem>();

            _blogArticleTypeService.GetAllList().ForEach(x =>
            {
                SelectListItem b = new SelectListItem();
                b.Text           = x.TypeName;
                b.Value          = x.Id.ToString();
                v.Add(b);
            });
            ArticleViewModel articleViewModel = new ArticleViewModel
            {
                BlogArticle      = article,
                BlogArticleTypes = v,
                ArticleAction    = articleAction
            };

            return(View(articleViewModel));
        }