Exemplo n.º 1
0
        public IActionResult RemoverItemDoCarrinhoCompra(int lancheId)
        {
            var lancheSelecionado = _lancheRepository.ListaLanches().Result.FirstOrDefault(p => p.LancheId == lancheId);

            if (lancheSelecionado != null)
            {
                _carrinhoCompra.RemoverItemCarrinho(lancheSelecionado);
            }
            return(RedirectToAction("Index"));
        }
Exemplo n.º 2
0
        public IActionResult List(string categoria)
        {
            string _categoria = categoria;
            IEnumerable <Lanche> lanches;
            string categoriaAtual = string.Empty;

            if (string.IsNullOrEmpty(categoria))
            {
                lanches        = _lancheRepository.ListaLanches().Result.OrderBy(p => p.LancheId);
                categoriaAtual = "Todos os lanches";
            }
            else
            {
                if (string.Equals("Normal", _categoria, StringComparison.OrdinalIgnoreCase))
                {
                    lanches = _lancheRepository.ListaLanches().Result.Where(p => p.Categoria.CategoriaNome.Equals("Normal")).OrderBy(p => p.Nome);
                }
                else
                {
                    lanches = _lancheRepository.ListaLanches().Result.Where(p => p.Categoria.CategoriaNome.Equals("Natural")).OrderBy(p => p.Nome);
                }

                categoriaAtual = _categoria;
            }

            var lancheListViewModel = new LancheListViewModel
            {
                Lanches        = lanches,
                CategoriaAtual = categoriaAtual
            };

            return(View(lancheListViewModel));
        }