/// <summary>
        /// Metodo que retorna la vista parcial de la tabla por defecto para ahorrar codigo
        /// </summary>
        /// <param name="file"></param>
        /// <returns></returns>
        private async Task <string> GetParcialView()
        {
            ListaCategoriaVm model = new ListaCategoriaVm();
            //obtenemos la lista de las secciones ingresadas
            FiltroCategoriaDto filtro = new FiltroCategoriaDto();

            filtro.Estado = Core.Enums.Estado.Activo;
            DataEntityPager <CategoriaOutput> result = await _categoriaService.GetCategoriasAsync(filtro, _cantXPage, model.Page);

            model.PagingInfo = new PagingInfo()
            {
                CurrentPage  = model.Page,
                ItemsPerPage = _cantXPage,
                TotalItems   = result.CantidadTotal
            };
            model.Categorias = result.Results;
            string htmlViewTable = await this.RenderViewAsync("_TablaCategoria", model);

            return(htmlViewTable);
        }
Beispiel #2
0
        public async Task <DataEntityPager <CategoriaOutput> > GetCategoriasAsync(FiltroCategoriaDto filtro, int itemperpage, int page)
        {
            //verificamos los parametros del filtro para poder verificar si vienen vacios
            bool isNullNombre = string.IsNullOrEmpty(filtro.Nombre);

            Expression <Func <Categoria, bool> > where = x => ((isNullNombre) || (x.NombreCategoria.Contains(filtro.Nombre)) && ((filtro.Estado == Core.Enums.Estado.Activo && x.Activo == true) ||
                                                                                                                                 (filtro.Estado == Core.Enums.Estado.Inactivo && x.Activo == false) || (filtro.Estado == Core.Enums.Estado.Todos)));

            List <Categoria> categorias = await _categoriaRepository.GetCategoriasAsync(where, itemperpage, page);

            List <CategoriaOutput> result = _mapper.Map <List <CategoriaOutput> >(categorias);
            int totalItems = await _categoriaRepository.CountAsync(where);

            DataEntityPager <CategoriaOutput> lista = new DataEntityPager <CategoriaOutput>();

            lista.CantidadPorPagina = itemperpage;
            lista.CantidadTotal     = totalItems;
            lista.PaginaActual      = page;
            lista.Results           = result;

            return(lista);
        }
        public async Task <IActionResult> Index(ListaCategoriaVm model)
        {
            FiltroCategoriaDto filtro = new FiltroCategoriaDto();

            filtro.Nombre = model.Nombre;
            if (model.Estado == null)
            {
                filtro.Estado = Core.Enums.Estado.Activo;
            }
            else
            {
                filtro.Estado = model.Estado;
            }
            DataEntityPager <CategoriaOutput> result = await _categoriaService.GetCategoriasAsync(filtro, _cantXPage, model.Page);

            model.PagingInfo = new PagingInfo()
            {
                CurrentPage  = model.Page,
                ItemsPerPage = _cantXPage,
                TotalItems   = result.CantidadTotal
            };
            model.Categorias = result.Results;
            return(View(model));
        }