public IActionResult Index(int?pagina) { Models.Cliente cliente = _loginCliente.BuscaClienteSessao(); PaginationEngine <Pedido> pedidos = _pedidoRepository.GeneratePagination(pagina, a => a.ClienteId == cliente.Id); return(View(pedidos)); }
public IActionResult EnderecoEntrega(int?pagina, string pesquisa) { ViewBag.Produtos = CarregarProdutoDB(); ViewBag.Cliente = _loginCliente.BuscaClienteSessao(); ViewBag.CEP = _cookie.Consultar("Carrinho.CEP", false); return(View(_enderecoEntregaRepository.GeneratePagination(pagina, pesquisa))); }
public IActionResult CadastroEnderecoEntrega([FromForm] EnderecoEntrega enderecoEntrega, string returnUrl) { if (ModelState.IsValid) { enderecoEntrega.ClienteId = _loginCliente.BuscaClienteSessao().Id; _enderecoEntregaRepository.Cadastrar(enderecoEntrega); if (string.IsNullOrEmpty(returnUrl)) { TempData["MSG_S"] = "Registro cadastrado com sucesso!"; return(RedirectToAction(nameof(CadastroEnderecoEntrega))); } else { return(Redirect(returnUrl)); } } return(View()); }
public void OnAuthorization(AuthorizationFilterContext context) { _loginCliente = (LoginCliente)context.HttpContext.RequestServices.GetService(typeof(LoginCliente)); Cliente cliente = _loginCliente.BuscaClienteSessao(); if (cliente == null) { context.Result = new RedirectToActionResult("Login", "Home", new { area = "Cliente" }); } }
private EnderecoEntrega ObterEndereco() { Cliente cliente = _loginCliente.BuscaClienteSessao(); string CEP = _cookie.Consultar("Carrinho.CEP", false); if (cliente.CEP.Replace("-", "") == CEP) { EnderecoEntrega endereco = new EnderecoEntrega(); endereco = _mapper.Map <EnderecoEntrega>(cliente); return(endereco); } return(_enderecoEntrega.ObterEndereco(a => a.CEP.Replace("-", "") == CEP && a.ClienteId == cliente.Id)); }
public IActionResult Index(int id) { Pedido pedido = _pedidoRepository.ObterPedido(id); if (pedido.ClienteId != _loginCliente.BuscaClienteSessao().Id) { return(new ForbidResult()); } ViewBag.Transacao = JsonConvert.DeserializeObject <TransacaoPagarMe>(pedido.DadosTransaction); ViewBag.Produtos = JsonConvert.DeserializeObject <List <ProdutoItem> >(pedido.DadosProdutos, new JsonSerializerSettings() { ContractResolver = new UndoJsonIgnore <List <ProdutoItem> >() }); return(View(pedido)); }
protected override ValidationResult IsValid(object value, ValidationContext validationContext) { LoginCliente _loginCliente = (LoginCliente)validationContext.GetService(typeof(LoginCliente)); IEnderecoEntregaRepository _enderecoEntregaRepository = (IEnderecoEntregaRepository)validationContext.GetService(typeof(IEnderecoEntregaRepository)); string CEP = value.ToString(); Cliente cliente = _loginCliente.BuscaClienteSessao(); EnderecoEntrega endereco = _enderecoEntregaRepository.ObterEndereco(a => a.CEP == CEP && a.ClienteId == cliente.Id); if (CEP == cliente.CEP || endereco != null) { return(new ValidationResult("O CEP já está cadastrado")); } return(ValidationResult.Success); }
public IActionResult AtualizarDados() { Models.Cliente cliente = _loginCliente.BuscaClienteSessao(); Models.Cliente clienteDB = _clienteRepository.ObterCliente(cliente.Id); return(View(clienteDB)); }
public Transaction GerarBoleto(decimal valor, EnderecoEntrega enderecoEntrega, ValorPrazoFrete frete, List <ProdutoItem> produtos) { Cliente cliente = _loginCliente.BuscaClienteSessao(); PagarMeService.DefaultApiKey = _conf.GetValue <string>("PagarMe:APIKey"); PagarMeService.DefaultEncryptionKey = _conf.GetValue <string>("PagarMe:EncriptionKey"); Transaction transaction = new Transaction(); transaction.Amount = (int)(valor * 100); transaction.PaymentMethod = PaymentMethod.Boleto; transaction.BoletoExpirationDate = DateTime.Now.AddDays(2); transaction.Customer = new Customer { ExternalId = cliente.Id.ToString(), Name = cliente.Nome, Type = CustomerType.Individual, Country = "br", Email = cliente.Email, Documents = new[] { new Document { Type = DocumentType.Cpf, Number = RemoverMascara(cliente.CPF) }, }, PhoneNumbers = new string[] { "+55" + RemoverMascara(cliente.Telefone), }, Birthday = cliente.Nascimento.ToString("yyyy-MM-dd") }; transaction.Shipping = new Shipping { Name = enderecoEntrega.Nome, Fee = (int)(frete.Valor * 100), DeliveryDate = DateTime.Now.AddDays(3 + frete.Prazo).ToString("yyyy-MM-dd"), Expedited = false, Address = new Address() { Country = "br", State = enderecoEntrega.Estado, City = enderecoEntrega.Cidade, Neighborhood = enderecoEntrega.Bairro, Street = enderecoEntrega.Rua, Complementary = enderecoEntrega.Complemento == null ? "" : enderecoEntrega.Complemento, StreetNumber = enderecoEntrega.Numero.ToString(), Zipcode = RemoverMascara(enderecoEntrega.CEP) } }; transaction.Item = new Item[produtos.Count]; for (int i = 0; i < produtos.Count; i++) { transaction.Item[i] = new Item() { Id = produtos[i].Id.ToString(), Title = produtos[i].Nome, Quantity = produtos[i].QuantidadeCarrinhoProduto, Tangible = true, UnitPrice = (int)(produtos[i].Valor * 100) }; } transaction.Save(); transaction.Customer.Gender = cliente.Sexo == "M" ? Gender.Male : Gender.Female; return(transaction); }
public IActionResult EnderecoEntrega() { ViewBag.Produtos = CarregarProdutoDB(); ViewBag.Cliente = _loginCliente.BuscaClienteSessao(); return(View()); }
public List <EnderecoEntrega> ObterTodosEnderecos() { Cliente cliente = _loginCliente.BuscaClienteSessao(); return(_banco.EnderecosEntrega.Where(a => a.ClienteId == cliente.Id).ToList()); }