public async Task <IActionResult> DadosPagamento(CheckoutViewModel model) { model.EnderecosUsuario = await _enderecoStore.ObterDoUsuario(User.Identity.Name); model.Carrinho = await _carrinhoStore.ObterCarrinho(User.Identity.Name); if (model.Carrinho == null) { TempData["ERRO"] = "Não há itens no carrinho"; return(RedirectToAction("Index", "Carrinho")); } if (!model.IsValid()) { model.Erro = "Concorde com os termos"; return(View(model)); } var pedido = model.GerarPedido(model.Carrinho, model.EnderecosUsuario); await _pedidoService.SalvarPedido(pedido, User.Identity.Name); await _carrinhoService.LimparCarrinho(User.Identity.Name); return(View("ConfirmarPedido", pedido)); }