Esempio n. 1
0
        public async Task <IActionResult> Novo()
        {
            var buscaCategoria = await categoriaServices.BuscaPorTudo();

            ViewBag.CategoriaList = new SelectList(buscaCategoria, "CategoriaId", "descricao");
            return(View());
        }
Esempio n. 2
0
        public async Task <IActionResult> Categorias(int?id)
        {
            var categorias = await categoriaServices.BuscaPorTudo();

            var categotiaTRUE = Mapper.Map <IEnumerable <Categoria>, IEnumerable <CategoriaViewModel> >(categorias);

            if (id == null)
            {
                var buscaPost = categorias.FirstOrDefault();
                if (buscaPost != null)
                {
                    buscaPost.Posts.Where(p => p.PreviaTexto.Length > 200).ToList().ForEach(p => p.PreviaTexto = p.PreviaTexto.Substring(0, 200) + " ....");
                    var post = Mapper.Map <IEnumerable <Posts>, IEnumerable <PostsViewModel> >(buscaPost.Posts);
                    ViewBag.PostList = post;
                }
            }
            else
            {
                var buscaPost = await categoriaServices.BuscaPorId(Convert.ToInt32(id));

                buscaPost.Posts.Where(p => p.PreviaTexto.Length > 200).ToList().ForEach(p => p.PreviaTexto = p.PreviaTexto.Substring(0, 200) + " ....");
                var post = Mapper.Map <IEnumerable <Posts>, IEnumerable <PostsViewModel> >(buscaPost.Posts);

                ViewBag.PostList = post;
            }
            return(View(categotiaTRUE));
        }
Esempio n. 3
0
        public async Task <IViewComponentResult> InvokeAsync()
        {
            var mapCategoria = Mapper.Map <IEnumerable <Categoria>, IEnumerable <CategoriaViewModel> >(await categoriaServices.BuscaPorTudo());

            return(View(mapCategoria));
        }