Example #1
0
        public IViewComponentResult Invoke()
        {
            var itens = _carrinhoCompra.GetCarrinhoCompraItens();

            //var itens = new List<CarrinhoCompraItem>() { new CarrinhoCompraItem(), new CarrinhoCompraItem() };

            //var itens = new List<CarrinhoCompraItem>();

            //var item1 = new CarrinhoCompraItem();
            //itens.Add(item1);

            //var item2 = new CarrinhoCompraItem();
            //itens.Add(item2);



            //para testar
            //var items = new List<CarrinhoCompraItem>() { new CarrinhoCompraItem(), new CarrinhoCompraItem() };
            _carrinhoCompra.CarrinhoCompraItens = itens;

            var carrinhoCompraVM = new CarrinhoCompraViewModel
            {
                CarrinhoCompra      = _carrinhoCompra,
                CarrinhoCompraTotal = _carrinhoCompra.GetCarrinhoCompraTotal()
            };

            return(View(carrinhoCompraVM));
        }
        public IActionResult Index()
        {
            _carrinhoCompra.Itens = _carrinhoCompra.GetItens();

            var carrinhoCompra = new CarrinhoCompraViewModel
            {
                CarrinhoCompra = _carrinhoCompra,
                Total          = _carrinhoCompra.GetValorTotal()
            };

            return(View(carrinhoCompra));
        }
Example #3
0
        public IActionResult Index()
        {
            var itens = _carrinhoCompra.GetCarrinhoCompraItens();
            _carrinhoCompra.CarrinhoCompraItens = itens;

            var carrinhoCompraViewModel = new CarrinhoCompraViewModel
            {
                CarrinhoCompra = _carrinhoCompra,
                CarrinhoCompraTotal = _carrinhoCompra.GetCarrinhoCompraTotal()
            };

            return View(carrinhoCompraViewModel);
        }
        //
        // GET: /CarrinhoCompra/
        public ActionResult Index()
        {
            var carrinho = CarrinhoCompra.ObterCarrinho(this.HttpContext);
            // Set up our ViewModel
            var viewModel = new CarrinhoCompraViewModel
            {
                CartItems     = carrinho.ObterCarrinhoItens(),
                CarrinhoTotal = carrinho.ObterTotal()
            };

            // Return the view
            return(View(viewModel));
        }
        //***********************************************************************************************************************************************************
        //***********************************************************************************************************************************************************
        //Exibe os itens adicionados no carrinho
        public IActionResult Index()
        {
            var itensDoCarrinho = _carrinhoCompra.ObterCarrinhoCompraItens();

            _carrinhoCompra.ItensCarrinhoCompras = itensDoCarrinho;

            CarrinhoCompraViewModel carrinhoCompraViewModel = new CarrinhoCompraViewModel
            {
                carrinhoCompra = _carrinhoCompra,
                TotalCarrinho  = _carrinhoCompra.ObterCarrinhoCompraTotal()
            };

            return(View(carrinhoCompraViewModel));
        }
Example #6
0
        public IActionResult Index()
        {
            var itens = _carrinhoCompra.GetCarrinhoCompraItens();

            _carrinhoCompra.CarrinhoCompraItens = itens;

            var carrinhoCompraVM = new CarrinhoCompraViewModel
            {
                CarrinhoCompra      = _carrinhoCompra,
                CarrinhoCompraTotal = Convert.ToDecimal(_carrinhoCompra.GetCarrinhoCompraTotal())
            };

            return(View(carrinhoCompraVM));
        }
Example #7
0
        public IActionResult Index() // exibe o carrinho com base na viewmodel
        {
            var itens = _carrinhoCompra.GetCarrinhoCompraItems();

            _carrinhoCompra.CarrinhoCompraItens = itens;

            var carrinhoCompraViewModel = new CarrinhoCompraViewModel
            {
                CarrinhoCompra      = _carrinhoCompra,
                CarrinhoCompraTotal = _carrinhoCompra.GetCarrinhoCompraTotal()
            };

            return(View(carrinhoCompraViewModel));
        }
Example #8
0
        public IViewComponentResult Invoke()
        {
            var itens = _carrinhoCompra.GetCarrinhoCompraItems();

            _carrinhoCompra.CarrinhoCompraItems = itens;

            var carrinhoCompraVM = new CarrinhoCompraViewModel
            {
                CarrinhoCompra      = _carrinhoCompra,
                CarrinhoCompraTotal = _carrinhoCompra.GetCarrinhoCompraTotal()
            };

            return(View());
        }
Example #9
0
        public IActionResult Index()
        {
            List <CarrinhoCompraItem> itens = _carrinhoCompra.GetCarrinhoCompraItens();

            _carrinhoCompra.ListCarrinhoCompraItens = itens;

            CarrinhoCompraViewModel carrinhoCompraViewModel = new CarrinhoCompraViewModel
            {
                CarrinhoCompra      = _carrinhoCompra,
                CarrinhoCompraTotal = _carrinhoCompra.GetCarrinhoCompraTotal()
            };

            return(View(carrinhoCompraViewModel));
        }
Example #10
0
        public async Task <IActionResult> Index()
        {
            var usuario = await _userManager.GetUserAsync(HttpContext.User);

            var produtosAdicionados = await _carrinhoCompraRepository.GetItemsForUserById(usuario.Id);

            var carrinhoVm = new CarrinhoCompraViewModel
            {
                CarrinhoCompraList = produtosAdicionados,
                ValorTotalItems    = _carrinhoCompraRepository.GetValorTotalDeItems(produtosAdicionados)
            };

            return(View(carrinhoVm));
        }
Example #11
0
        public IActionResult Index()
        {
            var itens = _carrinhoCompra.GetCarrinhoCompraItems();

            _carrinhoCompra.CarrinhoCompraItems = itens;

            var carrinhoCompraViewModel = new CarrinhoCompraViewModel
            {
                CarrinhoCompra = _carrinhoCompra,
                TotalCarrinho  = _carrinhoCompra.GetCarrinhoTotalCompra()
            };

            return(View(carrinhoCompraViewModel));
        }
Example #12
0
        public IViewComponentResult Invoke()
        {
            var itens = _carrinhoCompra.GetCarrinhoCompraItems();

            //var itens = new List<CarrinhoCompraItem>() {new CarrinhoCompraItem(), new CarrinhoCompraItem()};
            _carrinhoCompra.CarrinhoCompraItens = itens;
            var carrinhoCompraVm = new CarrinhoCompraViewModel
            {
                CarrinhoCompra      = _carrinhoCompra,
                CarrinhoCompraTotal = _carrinhoCompra.GetCarrinhoCompraTotal()
            };

            return(View(carrinhoCompraVm));
        }
Example #13
0
        public IActionResult Index()
        {
            var itens = _carrinhoCompra.GetCarrinhoCompraItens();

            _carrinhoCompra.CarrinhoCompraItens = itens;

            var carrinhoCompraViewModel = new CarrinhoCompraViewModel
            {
                CarrinhoCompra      = _carrinhoCompra,
                CarrinhoCompraTotal = _carrinhoCompra.GetCarrinhoCompraTotal()
            };

            // vai exibir o carrinho de compras com base na ViewModel
            return(View(carrinhoCompraViewModel));
        }
Example #14
0
        //Esse método Action exibe o carrinho de compras com base na minha ViewModel
        public IActionResult Index()
        {
            var itens = _carrinhoCompra.GetCarrinhoCompraItens();

            _carrinhoCompra.CarrinhoCompraItens = itens;

            var carrinhoDeCompraViewModel = new CarrinhoCompraViewModel
            {
                //ter acesso as propriedades do carrinho de compra
                CarrinhoCompra      = _carrinhoCompra,
                CarrinhoCompraTotal = _carrinhoCompra.GetCarrinhoCompraTotal()
            };

            return(View(carrinhoDeCompraViewModel));
        }
        public IViewComponentResult Invoke()
        {
            //_carrinhoCompra.Itens = _carrinhoCompra.GetItens();
            _carrinhoCompra.Itens = new List <CarrinhoCompraItem>()
            {
                new CarrinhoCompraItem(), new CarrinhoCompraItem()
            };
            var carrinhoCompraViewModel = new CarrinhoCompraViewModel
            {
                CarrinhoCompra = _carrinhoCompra,
                Total          = _carrinhoCompra.GetValorTotal()
            };

            return(View(carrinhoCompraViewModel));
        }
Example #16
0
        public IViewComponentResult Invoke()
        {
            var items = _carrinhoCompra.GetCarrinhoCompraItens();

            //para testar
            //var items = new List<CarrinhoCompraItem>() { new CarrinhoCompraItem(), new CarrinhoCompraItem() };
            _carrinhoCompra.CarrinhoCompraItens = items;

            var carrinhoCompraVM = new CarrinhoCompraViewModel
            {
                CarrinhoCompra      = _carrinhoCompra,
                CarrinhoCompraTotal = Convert.ToDecimal(_carrinhoCompra.GetCarrinhoCompraTotal())
            };

            return(View(carrinhoCompraVM));
        }
Example #17
0
        public IViewComponentResult Invoke() 
        {
            var itens = _carrinhoCompra.GetCarrinhoCompraItens();

           //var itens = new System.Collections.Generic.List<CarrinhoCompraItem>() { new CarrinhoCompraItem(), new CarrinhoCompraItem()};

            _carrinhoCompra.CarrinhoCompraItens = itens;

            var carrinhoCompraVM = new CarrinhoCompraViewModel
            {
                CarrinhoCompra = _carrinhoCompra,
                CarrinhoCompraTotal = _carrinhoCompra.GetCarrinhoCompraTotal()
            };

            return View(carrinhoCompraVM);
        }
Example #18
0
        public async Task <IActionResult> ItensCarrinhoResumo()
        {
            Usuario usuario = await _userManager.GetUserAsync(HttpContext.User);

            var carrinhoVm = new CarrinhoCompraViewModel();

            if (usuario != null)
            {
                var produtosAdicionados = await _carrinhoCompraRepository.GetItemsForUserById(usuario.Id);

                carrinhoVm.CarrinhoCompraList = produtosAdicionados;
                carrinhoVm.ValorTotalItems    = _carrinhoCompraRepository.GetValorTotalDeItems(produtosAdicionados);
            }

            return(Json(carrinhoVm));
        }
Example #19
0
        public IViewComponentResult Invoke()
        {
            var itens = _carrinhoCompra.GetCarrinhoCompraItems();// obter itens do carrinho

            //var itens = new List<CarrinhoCompraItem>() { new CarrinhoCompraItem(), new CarrinhoCompraItem() };


            _carrinhoCompra.CarrinhoCompraItens = itens;

            var carrinhoCompraVM = new CarrinhoCompraViewModel
            {
                CarrinhoCompra      = _carrinhoCompra,
                CarrinhoCompraTotal = _carrinhoCompra.GetCarrinhoCompraTotal()
            };

            return(View(carrinhoCompraVM)); // retorna o carrinho e o total do carrinho
        }
Example #20
0
        public IViewComponentResult Invoke()
        {
            // obter itens do carrinho
            var itens = _carrinhoCompra.GetCarrinhoCompraItens();

            /* var itens = new List<CarrinhoCompraItem>() { new CarrinhoCompraItem(), new CarrinhoCompraItem() }; */

            _carrinhoCompra.CarrinhoCompraItens = itens;

            var carrinhoCompraVM = new CarrinhoCompraViewModel
            {
                CarrinhoCompra      = _carrinhoCompra,
                CarrinhoCompraTotal = _carrinhoCompra.GetCarrinhoCompraTotal()
            };

            return(View(carrinhoCompraVM));
        }
Example #21
0
        public IViewComponentResult Invoke()
        {
            try
            {
                var carrinhoVM = new CarrinhoCompraViewModel();
                if (User.Identity.IsAuthenticated)
                {
                    Usuario usuario = _userManager.GetUserAsync(HttpContext.User).Result;
                    var     carrinhoComprasForUser = _carrinhoRepository.GetItemsForUserById(usuario.Id).Result;
                    carrinhoVM.CarrinhoCompraList = carrinhoComprasForUser;
                    carrinhoVM.TotalItems         = carrinhoComprasForUser.Count;

                    return(View(carrinhoVM));
                }

                return(View(carrinhoVM));
            }
            catch (Exception)
            {
                return(View());
            }
        }