public CarrinhoViewModel RemoverItemDoCarrinho(CarrinhoViewModel carrinhoViewModel, Guid itemCarrinhoId)
        {
            var carrinho = BindCarrinhoViewModelToCarrinho(carrinhoViewModel);

            carrinho = this.carrinhoService.RemoverItemDoCarrinho(carrinho, itemCarrinhoId);

            return BindCarrinhoToCarrinhoViewModel(carrinho);
        }
        public CarrinhoViewModel EditarItemCarrinho(CarrinhoViewModel carrinhoViewModel, ItemCarrinhoViewModel itemCarrinhoViewModel)
        {
            var carrinho = BindCarrinhoViewModelToCarrinho(carrinhoViewModel);
            var itemCarrinho = Mapper.Map<ItemCarrinhoViewModel, ItemCarrinho>(itemCarrinhoViewModel);

            var carrinhoResult = this.carrinhoService.EditarItemCarrinho(carrinho, itemCarrinho);

            return BindCarrinhoToCarrinhoViewModel(carrinhoResult);
        }
        public CarrinhoViewModel AdicionarItemNoCarrinho(CarrinhoViewModel carrinhoViewModel, ItemCarrinhoViewModel itemCarrinhoViewModel)
        {
            var carrinho = BindCarrinhoViewModelToCarrinho(carrinhoViewModel);
            var itemCarrinho = Mapper.Map<ItemCarrinhoViewModel, ItemCarrinho>(itemCarrinhoViewModel);

            carrinho = this.carrinhoService.AdicionarItemNoCarrinho(carrinho, itemCarrinho);

            return BindCarrinhoToCarrinhoViewModel(carrinho);
        }
        public Carrinho BindCarrinhoViewModelToCarrinho(CarrinhoViewModel carrinhoViewModel)
        {
            var carrinho = Mapper.Map<CarrinhoViewModel, Carrinho>(carrinhoViewModel);
            foreach (var itemViewModel in carrinhoViewModel.Itens)
            {
                carrinho.AdicionarItem(Mapper.Map<ItemCarrinhoViewModel, ItemCarrinho>(itemViewModel));
            }

            return carrinho;
        }
        public ActionResult DetalheCarrinho()
        {
            CarrinhoViewModel carrinho = new CarrinhoViewModel();

            var carrinhoSession = Session["Carrinho"];

            if (carrinhoSession != null)
                carrinho = (CarrinhoViewModel)carrinhoSession;
            else
                Session["Carrinho"] = carrinho;

            return PartialView("_DetalheCarrinho", carrinho);
        }
        public ActionResult AddItem(ItemCarrinhoViewModel itemCarrinho)
        {
            CarrinhoViewModel carrinho = new CarrinhoViewModel();

            var carrinhoSession = Session["Carrinho"];

            if (carrinhoSession != null)
                carrinho = (CarrinhoViewModel)carrinhoSession;

            var carrinhoViewModel = this.carrinhoAppService.AdicionarItemNoCarrinho(carrinho, itemCarrinho);

            Session["Carrinho"] = carrinhoViewModel;

            return PartialView("_DetalheCarrinho", carrinhoViewModel);
        }
        public ItemCarrinhoViewModel SelecionarItemCarrinhoPorId(CarrinhoViewModel carrinhoViewModel, Guid itemCarrinhoId)
        {
            var carrinho = BindCarrinhoViewModelToCarrinho(carrinhoViewModel);

            return Mapper.Map<ItemCarrinho, ItemCarrinhoViewModel>(this.carrinhoService.SelecionarItemCarrinhoPorId(carrinho, itemCarrinhoId));
        }