Ejemplo n.º 1
0
        public IActionResult Index()
        {
            var viewModel = new ProductosIndexViewModel()
            {
                Productos = _productos.GetAllWithFormatedStock(SucursalId)
            };

            return(View(viewModel));
        }
        public IActionResult Index(ProductosIndexViewModel vm)
        {
            fruteriashopContext  context         = new fruteriashopContext();
            CategoriasRepository categoriasRepos = new CategoriasRepository(context);
            ProductosRepository  productosRepos  = new ProductosRepository(context);

            vm.Categorias = categoriasRepos.GetAll();
            vm.Productos  = productosRepos.GetProductosByCategoria(vm.IdCategoria);
            return(View(vm));
        }
Ejemplo n.º 3
0
        public IActionResult Index()
        {
            ProductosIndexViewModel pivm    = new ProductosIndexViewModel();
            fruteriashopContext     context = new fruteriashopContext();
            CategoriasRepository    cr      = new CategoriasRepository(context);
            ProductosRepository     pr      = new ProductosRepository(context);
            int?id = null;

            pivm.Categorias = cr.GetAll();
            pivm.Productos  = pr.GetProductosByCategoria(id);
            return(View(pivm));
        }
Ejemplo n.º 4
0
        public IActionResult Index()
        {
            ProductosIndexViewModel vm      = new ProductosIndexViewModel();
            fruteriashopContext     context = new fruteriashopContext();
            CategoriasRepository    categoriasRepository = new CategoriasRepository(context);
            ProductosRepository     productosRepository  = new ProductosRepository(context);

            int?id = null;

            vm.Categorias = categoriasRepository.GetAll().Where(x => x.Eliminado == 0);
            vm.Productos  = productosRepository.GetProductosByCategoria(id);

            return(View(vm));
        }
        public IActionResult Index()
        {
            ProductosIndexViewModel vm      = new ProductosIndexViewModel();
            fruteriashopContext     context = new fruteriashopContext();
            //Una sola conexion pero dla utilizan los dos repositorios
            CategoriasRepository categoriasrepository = new CategoriasRepository(context);
            ProductosRepository  productosRepository  = new ProductosRepository(context);

            int?id = 0;

            vm.Categorias = categoriasrepository.GetAll();
            vm.Productos  = productosRepository.GetProductosByCategoria(id);

            return(View(vm));
        }
Ejemplo n.º 6
0
        public IActionResult Index()
        {
            ProductosIndexViewModel vm             = new ProductosIndexViewModel();
            fruteriashopContext     context        = new fruteriashopContext();
            CategoriasRepository    categoriarepos = new CategoriasRepository(context);
            ProductosRepository     productosrepos = new ProductosRepository(context);


            int?id = null;

            // AGREGUÉ EL WHERE PARA QUE NO SE MUESTRE LA CATEGORÍA SI FUÉ ELIMINADA DE MANERA LOGICA
            vm.Categorias = categoriarepos.GetAll().Where(x => x.Eliminado == false).OrderBy(x => x.Nombre);
            vm.Productos  = productosrepos.GetProductosByCategoria(id);


            return(View(vm));
        }