public ActionResult Listagem(int? page) { page = page ?? 1; var parametro = new ParametroService().GetByPage(page.Value); var list = new MvcList<Parametro>(parametro.Item1, page.Value, parametro.Item2, Settings.QuantityRegistersPerPage); return PartialView(list); }
public ActionResult SaveParameters(List<Parametro> parametros) { var parametro = new ParametroService(); if (parametros != null) { parametro.ParametersCheck(parametros); } return Json(new JsonRequestResult { ResultType = JsonRequestResultType.Success, Message = Constants._msgUpdateSuccess, ReturnUrl = Url.Content("~/Admin/Parametro/") }); }
public void IncluirParametro() { // Arrange var parametro1 = new Parametro { AlteradoEm = DateTime.Now, AlteradoPor = 1, Codigo = "NUM_QUESTOES_CORTESIA", Valor = "10" }; var parametro2 = new Parametro { AlteradoEm = DateTime.Now, AlteradoPor = 1, Codigo = "CORTESIA_MANUTENCAO_DIAS", Valor = "30" }; var parametro3 = new Parametro { AlteradoEm = DateTime.Now, AlteradoPor = 1, Codigo = "NOTA_MINIMA", Valor = "85" }; var parametro4 = new Parametro { AlteradoEm = DateTime.Now, AlteradoPor = 1, Codigo = "PRAZO_ACESSO_PAGO", Valor = "1" }; var parametro5 = new Parametro { AlteradoEm = DateTime.Now, AlteradoPor = 1, Codigo = "PAYPAL_PRICE_30D", Valor = "30.00" }; var service = new ParametroService(); // Act parametro1.Id = service.Gravar(parametro1); parametro2.Id = service.Gravar(parametro2); parametro3.Id = service.Gravar(parametro3); parametro4.Id = service.Gravar(parametro4); // Assert Assert.AreEqual(1, parametro1.Id); Assert.AreEqual(2, parametro2.Id); Assert.AreEqual(3, parametro3.Id); Assert.AreEqual(4, parametro4.Id); }
public CabecalhoTemplate( string corpoTemplateHtml, string titulo, string descricao, ParametroService parametroService, EmpresaService empresaService, UsuarioService usuarioService) { _templateHtml = corpoTemplateHtml; _titulo = titulo; _descricao = descricao; _parametroService = parametroService; _empresaService = empresaService; _usuarioService = usuarioService; }
public ActionResult Index() { // Get Parametros var tipoParametro = ((Int32)TipoParametro.ConfiguracaoDaHome); var parameters = new ParametroService().GetRecords(p => p.IdTipoParametro == tipoParametro); if (parameters != null && parameters.Count > 0) { ViewBag.Address = parameters.FirstOrDefault(p => p.Nome == "Endereco"); ViewBag.Phone = parameters.FirstOrDefault(p => p.Nome == "Telefone"); } tipoParametro = ((Int32)TipoParametro.PesquisaDoCliente); parameters = new ParametroService().GetRecords(p => p.IdTipoParametro == tipoParametro); if (parameters != null && parameters.Count > 0) { ViewBag.PesquisaDoCliente = GetSearchItemsSelectList(parameters, Resource.Label_EC_Selecione); } return View(new ContatoModel()); }
public ParametroController(ILogger <ParametroController> logger) { _logger = logger; ps = new ParametroService(_logger); }
public ConfiguracionController() { _parametroService = new ParametroService(); }
public ParametroController(ParametroService servico) { _servico = servico; }
public IHttpActionResult GuardarParametros([FromBody] Parametro param) { ParametroService con = new ParametroService(); return(Ok(con.GuardarParametros(param))); }
/// <summary> /// Form to submit values to gateway /// </summary> /// <param name="id">idPedido</param> /// <returns></returns> public ActionResult Payment(int id) { if (User.Identity.IsAuthenticated) { ViewBag.Title = Resources.Resource.Pagamento_Titulo; //get order details var idPedido = new PedidoService().GetRecords(x => x.NumeroPedido == id).FirstOrDefault().IdPedido; var pedido = new PedidoService().GetById(idPedido, GetCurrentIdIdioma()); if (pedido.Status == StatusPedido.AguardandoPagamento && FormsAuthenticationUtil.UserAuthenticated.IdCliente.HasValue && FormsAuthenticationUtil.UserAuthenticated.IdCliente.Value == pedido.IdCliente) { //get shipping address details var endereco = new EnderecoService().GetShippingAddress(pedido.IdPedido); var cultureInfo = new CultureInfo("en-US"); var rgService = new RequestGatewayService(); rgService.Model = new RequestGatewayModel { PedidoNumero = pedido.Numero.HasValue ? pedido.Numero.Value.ToString(CultureInfo.InvariantCulture) : string.Empty, PedidoValorFrete = pedido.ValorFrete.ToString(cultureInfo), PedidoValorTaxas = pedido.ValorTaxa.ToString(cultureInfo), PedidoValorManuseio = pedido.ValorManuseio.ToString(cultureInfo), PedidoSubTotal = pedido.Subtotal.ToString(cultureInfo), PedidoTotal = pedido.Total.ToString(cultureInfo), ClienteId = pedido.IdCliente.ToString(CultureInfo.InvariantCulture), ClienteSobrenome = pedido.NomeCliente.Trim().Split(' ').Length > 1 ? pedido.NomeCliente.Trim().Split(' ')[0] : pedido.NomeCliente.Trim(), ClienteNome = pedido.NomeCliente.Trim().Split(' ').Length > 1 ? pedido.NomeCliente.Trim().Substring(pedido.NomeCliente.IndexOf(' '), pedido.NomeCliente.Trim().Length - pedido.NomeCliente.Trim().IndexOf(' ')) : string.Empty, EnderecoCep = endereco.Cep, EnderecoLogradouro = endereco.Logradouro, EnderecoCidade = endereco.IdCidade != null ? endereco.Cidade1.Nome : endereco.Cidade, EnderecoEstado = endereco.IdEstado != null ? endereco.Estado.Nome : string.Empty, EnderecoEmail = endereco.EmailEntrega, EnderecoTelefone = endereco.TelefoneEntrega }; switch (pedido.FormaPagamento) { case FormaPagamento.Authorize: var parameters = new ParametroService().GetByParameterType((int)TipoParametro.FormaDePagamento); var apiLogin = parameters.Where(x => x.Nome == "Login ApI").FirstOrDefault(); var transKey = parameters.Where(x => x.Nome == "Transaction Key").FirstOrDefault(); var urlResponse = parameters.Where(x => x.Nome == "Url de retorno Authorize").FirstOrDefault(); if (apiLogin != null && transKey != null && urlResponse != null) { rgService.QueryString = Settings.AuthorizeQueryString; rgService.Model.GatewayUsuario = apiLogin.Valor; rgService.Model.GatewayUrlRequest = Settings.AuthorizeRequest; rgService.Model.GatewayUrlResponse = urlResponse.Valor; rgService.AdicionalParameters = new Dictionary<String, String>(); var timeStamp = ((int)(DateTime.UtcNow - new DateTime(1970, 1, 1)).TotalSeconds).ToString(); string fingerprint = WebHelpers.HMAC_MD5(transKey.Valor, rgService.Model.GatewayUsuario + "^" + rgService.Model.PedidoNumero + "^" + timeStamp + "^" + rgService.Model.PedidoTotal + "^"); rgService.AdicionalParameters.Add("timeStamp", timeStamp); rgService.AdicionalParameters.Add("fingerprint", fingerprint); } return View(rgService); case FormaPagamento.Paypal: var parametros = new ParametroService().GetByParameterType((int)TipoParametro.FormaDePagamento); var business = parametros.Where(x => x.Nome == "Business").FirstOrDefault().Valor; var urlRetorno = parametros.Where(x => x.Nome == "Url de retorno Paypal").FirstOrDefault().Valor; var urlNotificacao = parametros.Where(x => x.Nome == "Url de notificação").FirstOrDefault().Valor; var urlImagem = parametros.Where(x => x.Nome == "Url da Imagem").FirstOrDefault().Valor; rgService.QueryString = Settings.PaypalQueryString; rgService.Model.GatewayUsuario = business; rgService.Model.GatewayUrlRequest = Settings.PaypalRequest; rgService.Model.GatewayUrlResponse = urlRetorno; rgService.AdicionalParameters = new Dictionary<string, string>(); rgService.AdicionalParameters.Add("lc", "PT");// CultureInfo.CurrentUICulture.TextInfo.CultureName.Split('-')[1] rgService.AdicionalParameters.Add("image_url", urlImagem); rgService.AdicionalParameters.Add("notify_url", urlNotificacao); return View(rgService); case FormaPagamento.BoletoBradesco: var paramBoleto = new ParametroService().GetByParameterType((int)TipoParametro.FormaDePagamento); var urlBoleto = paramBoleto.FirstOrDefault(m => m.Nome == "Boleto Bradesco URL") ?? new Parametro(); var numLoja = paramBoleto.FirstOrDefault(m => m.Nome == "Boleto Bradesco Numero Loja") ?? new Parametro(); rgService.Model.PedidoNumero = idPedido.ToString(CultureInfo.InvariantCulture); rgService.Model.GatewayUrlRequest = string.Format(urlBoleto.Valor, numLoja.Valor, id); rgService.QueryString = string.Format(Settings.BoletoBradescoQueryString, numLoja.Valor, id); return View("PaymentBoleto", rgService); default: return AccessDenied(); } } } return AccessDenied(); }
public ActionResult ConfirmationBoletoBradesco() { //PARAMETERS "transId","numOrder","merchantid","cod","cctype","ccna me","ccemail","numparc","valparc","valtotal","prazo","tipopagto","assinatura", var numOrder = Request.Form["numOrder"]; var numeroPedido = int.Parse(numOrder); var parameters = new ParametroService().GetByParameterType((int)TipoParametro.FormaDePagamento); var banco = parameters.FirstOrDefault(m => m.Nome == "Boleto Bradesco Banco"); var agencia = parameters.FirstOrDefault(m => m.Nome == "Boleto Bradesco Numero Agencia"); var conta = parameters.FirstOrDefault(m => m.Nome == "Boleto Bradesco Numero Conta"); var assinatura = parameters.FirstOrDefault(m => m.Nome == "Boleto Bradesco Assinatura"); var diasPagamento = parameters.FirstOrDefault(m => m.Nome == "Boleto Bradesco Dias Vencimento"); int diasPgto = int.Parse(diasPagamento.Valor); var sb = new StringBuilder(); var pedido = new PedidoService().GetByNumero(numeroPedido); if (pedido != null) { sb.Append("<BEGIN_ORDER_DESCRIPTION>"); sb.Append(string.Format("<orderid>=({0})", numOrder)); foreach (var item in pedido.Ecommerce_PedidoItem.ToList()) { var produto = new ProdutoService().GetById(item.IdProduto); sb.Append(string.Format("<descritivo>=({0})", produto.Nome)); sb.Append(string.Format("<quantidade>=({0})", item.QuantidadeProduto)); sb.Append(string.Format("<unidade>=({0})", "UN")); sb.Append(string.Format("<valor>=({0})", Math.Round((item.ValorProduto * item.QuantidadeProduto) * 100), 0)); } sb.Append("<adicional>=(frete)"); sb.Append(string.Format("<valorAdicional>=({0})", Math.Round(pedido.ValorFrete.GetValueOrDefault() * 100),0)); if(pedido.ValorTaxaManuseio.GetValueOrDefault() > 0) { sb.Append("<adicional>=(manuseio)"); sb.Append(string.Format("<valorAdicional>=({0})",Math.Round(pedido.ValorTaxaManuseio.GetValueOrDefault() * 100),0)); } sb.Append("<END_ORDER_DESCRIPTION>"); sb.Append("<BEGIN_BOLETO_DESCRIPTION>"); sb.Append(string.Format("<CEDENTE>=({0})",Resources.Resource.BoletoBradesco_Cedente)); if (banco != null) sb.Append(string.Format("<BANCO>=({0})", banco.Valor)); if (agencia != null) sb.Append(string.Format("<NUMEROAGENCIA>=({0})", agencia.Valor)); if (conta != null) sb.Append(string.Format("<NUMEROCONTA>=({0})", conta.Valor)); if (assinatura != null) sb.Append(string.Format("<ASSINATURA>=({0})", assinatura.Valor)); sb.Append(string.Format("<DATAEMISSAO>=({0})", DateTime.Today.ToString("dd/MM/yyyy"))); sb.Append(string.Format("<DATAPROCESSAMENTO>=({0})", DateTime.Today.ToString("dd/MM/yyyy"))); sb.Append(string.Format("<DATAVENCIMENTO>=({0})", DateTime.Today.AddDays(diasPgto).ToString("dd/MM/yyyy"))); sb.Append(string.Format("<NOMESACADO>=({0})",pedido.Ecommerce_Cliente.NomeCompleto)); sb.Append(string.Format("<ENDERECOSACADO>=({0}, {1})", pedido.Ecommerce_PedidoEndereco.Logradouro, pedido.Ecommerce_PedidoEndereco.Numero)); sb.Append(string.Format("<CIDADESACADO>=({0})",pedido.Ecommerce_PedidoEndereco.Cidade)); sb.Append(string.Format("<UFSACADO>=({0})",pedido.Ecommerce_PedidoEndereco.Estado.Prefixo)); sb.Append(string.Format("<CEPSACADO>=({0})",pedido.Ecommerce_PedidoEndereco.Cep.PadRight(8,'0'))); sb.Append(string.Format("<CPFSACADO>=({0})",(pedido.Ecommerce_Cliente.Documento ?? "").PadRight(11,'0'))); sb.Append(string.Format("<NUMEROPEDIDO>=({0})",numOrder)); sb.Append(string.Format(CultureInfo.CreateSpecificCulture("pt-BR"),"<VALORDOCUMENTOFORMATADO>=({0:C})", pedido.ValorTotal.GetValueOrDefault()).Replace(" ","")); sb.Append("<SHOPPINGID>=(1)"); sb.Append(string.Format("<NUMDOC>=({0})",numOrder)); sb.Append("<END_BOLETO_DESCRIPTION>"); } ViewBag.XML = sb.ToString(); return View(); }
public ActionResult ConfirmationAuthorize(int? id) { try { if (Request.RequestType == "POST") { int invoiceNumber = 0; if (Request.Params["x_invoice_num"] != null) invoiceNumber = Convert.ToInt32(Request.Params["x_invoice_num"]); var pedido = new PedidoService().GetRecords(x => x.NumeroPedido == invoiceNumber).FirstOrDefault(); //Verify order if (pedido != null) { var parameters = new ParametroService().GetByParameterType((int)TipoParametro.FormaDePagamento); var authorizeHashMD5 = parameters.Where(x => x.Nome == "MD5 Hash").FirstOrDefault(); var apiLogin = parameters.Where(x => x.Nome == "Login ApI").FirstOrDefault(); var transKey = parameters.Where(x => x.Nome == "Transaction Key").FirstOrDefault(); var urlResponse = parameters.Where(x => x.Nome == "Url de retorno Authorize").FirstOrDefault(); var transId = Request.Params["x_trans_id"] != null ? Request.Params["x_trans_id"] : string.Empty; var ammount = Request.Params["x_amount"] != null ? Convert.ToDecimal(Request.Params["x_amount"]) : 0; var md5HashValidator = HashValueToMD5(authorizeHashMD5.Valor + apiLogin.Valor + transId + ammount); var md5HashFromAuthorize = Request.Params["x_MD5_Hash"] != null ? Request.Params["x_MD5_Hash"] : string.Empty; if (md5HashFromAuthorize == md5HashValidator) { if (pedido.IdFormaPagamento == (int)FormaPagamento.Authorize) { var retorno = new Ecommerce_RetornoPagamento { IdPedido = pedido.IdPedido, DataInclusao = DateTime.Now, IdFormaPagamento = pedido.IdFormaPagamento.Value, Resultado = Request.Params.ToString() //TODO: Serializar e salvar em XML (rvsm) }; new PedidoService().InsertRetornoPagamento(retorno); } else { var ex = new Exception(Resources.Resource.Msg_Order_MetodoPagamentoInvalido); LogService.Log("Order.ConfirmationAuthorize()", ex.Message, TipoLog.Erro); throw ex; } //Atualiza o status do pedido pedido.StatusPedido = (int)StatusPedido.EmProcessamento; new PedidoService().UpdateObject(pedido); return PartialView("ConfirmationAuthorize", pedido.IdPedido); } throw new Exception(Resources.Resource.Msg_Order_TransacaoNaoValidada); } throw new Exception(Resources.Resource.Msg_Order_TransacaoNaoDetectada); } throw new Exception(Resources.Resource.Msg_Order_NaoHouveResposta); } catch (Exception ex) { LogService.Log("Order.ConfirmationAuthorize()", ex.Message, TipoLog.Erro); throw ex; } }
public IHttpActionResult GetLast() { ParametroService con = new ParametroService(); return(Ok(con.GetLast())); }
/// <summary> /// Retrieve shipping rate /// </summary> /// <param name="zipcode"></param> /// <param name="peso"></param> /// <returns></returns> public Decimal GetShippingPriceUPS(String zipcode, Decimal peso) { if (String.IsNullOrWhiteSpace(zipcode)) { return new Decimal(0); } //recupera os valores dos parametros para UPS var parameters = new ParametroService().GetByParameterType((int)TipoParametro.TipoDeEntrega); var login = parameters.Where(x => x.Nome == "UPS Login ID").FirstOrDefault().Valor; var password = parameters.Where(x => x.Nome == "UPS Password").FirstOrDefault().Valor; var access = parameters.Where(x => x.Nome == "UPS Access").FirstOrDefault().Valor; var service = parameters.Where(x => x.Nome == "UPS Service").FirstOrDefault().Valor; var ups = new UPS(access, login, password, service, Settings.WebServiceUPS); decimal minimumWeight = (decimal)0.100; peso = peso < minimumWeight ? minimumWeight : peso; var totalShipping = ups.GetShipRate(zipcode, peso); return totalShipping; }
/// <summary> /// Confirma o pedido do Paypal e salva os detalhes /// </summary> /// <param name="transactionId"></param> /// <returns></returns> protected PedidoModel ConfirmPaypalOrder(string transactionId) { var parameters = new ParametroService().GetByParameterType((int)TipoParametro.FormaDePagamento); var token = parameters.Where(x => x.Nome == "Token").FirstOrDefault().Valor; //Build a url to call Paypal and get data about the Transaction //ex. url?cmd=_notify-synch&tx=[TransactionID]&at=[PDTIdentityToken] var query = string.Format("cmd=_notify-synch&tx={0}&at={1}", transactionId, token); var urlRequest = Settings.PaypalRequest; var requestUrl = string.Format("{0}?{1}", urlRequest, query); var req = (HttpWebRequest)WebRequest.Create(requestUrl); req.Method = "POST"; req.ContentType = "application/x-www-form-urlencoded"; req.ContentLength = query.Length; var stOut = new StreamWriter(req.GetRequestStream(), Encoding.ASCII); stOut.Write(query); stOut.Close(); // Do the request to PayPal and get the response var stIn = new StreamReader(req.GetResponse().GetResponseStream()); var strResponse = stIn.ReadToEnd(); stIn.Close(); // If response was SUCCESS, parse response string and output details if (strResponse.StartsWith("SUCCESS")) { //Verify order var idPedido = UpdatePaypalTransaction(strResponse); try { //Generate Comission bool resultComission = new WS.Commissions.Commissions().GenerateCommissions(Settings.AutenticationKeyEarningSystem, idPedido, GetIdClientCookie(this)); } catch (Exception ex) { LogService.Log("WS.Commissions.Commissions().GenerateCommissions()", ex.Message, TipoLog.Erro); } if (idPedido != 0) { var pedido = new PedidoService().GetById(idPedido, GetCurrentIdIdioma()); return pedido; } throw new Exception(Resources.Resource.Msg_Order_PedidoNaoEncontrado); } throw new Exception(Resources.Resource.Msg_Order_MensagemNaoValidadaPaypal); }
private Decimal GetShippingPriceCorreios(String zipcode, Decimal peso, String codServico, Decimal comprimento, Decimal altura, Decimal largura, Decimal diametro, ref CarrinhoModel carrinho) { if (String.IsNullOrWhiteSpace(zipcode)) { return new Decimal(0); } //recupera os valores dos parametros para Correios var parameters = new ParametroService().GetByParameterType((int)TipoParametro.TipoDeEntrega); var cdCorreios = parameters.FirstOrDefault(x => "Código Correios" == x.Nome); var senhaCorreios = parameters.FirstOrDefault(x => "Senha Correios" == x.Nome); var maoPropria = parameters.FirstOrDefault(x => "Entrega mão propria Correios[S/N]" == x.Nome); var valorDeclarado = parameters.FirstOrDefault(x => "Entrega com valor declarado Correios[S/N]" == x.Nome); var avisoRecebimento = parameters.FirstOrDefault(x => "Entrega com aviso de recebimento Correios[S/N]" == x.Nome); var cepOrigem = parameters.FirstOrDefault(x => "Cep Origem Correios" == x.Nome); if (largura < 11) { largura = 11; } if (comprimento < 16) { comprimento = 16; } if (altura < 2) { altura = 2; } var correio = new CalcPrecoPrazoWS(); var retorno = correio.CalcPrecoPrazo(cdCorreios.Valor, senhaCorreios.Valor, codServico, cepOrigem.Valor, zipcode, peso.ToString(CultureInfo.InvariantCulture), 1, comprimento, altura, largura, diametro, maoPropria.Valor, 0, avisoRecebimento.Valor); if (retorno.Servicos.Any()) { var valor = retorno.Servicos[0].Valor.Replace(",", ""); int prazo; int.TryParse(retorno.Servicos[0].PrazoEntrega, out prazo); carrinho.PrazoEntrega = prazo; return decimal.Parse(valor) / 100; } return new Decimal(0); }
public IHttpActionResult ActualizarParametro([FromBody] Parametro param) { ParametroService con = new ParametroService(); return(Ok(con.ActualizarParametros(param))); }