Beispiel #1
0
        public Boolean ConsultTransaction(String code, Instituicao oInstituicao)
        {
            PagSeguroPagamento oPagSeguroPagamento = new PagSeguroPagamento();

            string urlPagSeguro = System.Configuration.ConfigurationManager.AppSettings["pagSeguroURL_CONSULT"];

            urlPagSeguro = urlPagSeguro.Replace("#email#", oInstituicao.email);
            urlPagSeguro = urlPagSeguro.Replace("#token#", oInstituicao.token);
            urlPagSeguro = urlPagSeguro.Replace("#code#", code);

            using (var client = new HttpClient())
            {
                var values   = new Dictionary <string, string>();
                var content  = new FormUrlEncodedContent(values);
                var response = client.GetAsync(urlPagSeguro).Result;


                if (response.IsSuccessStatusCode)
                {
                    var responseContent = response.Content;

                    // by calling .Result you are synchronously reading the result
                    string      responseString = responseContent.ReadAsStringAsync().Result;
                    XmlDocument xml            = new XmlDocument();
                    xml.LoadXml(responseString);

                    oPagSeguroPagamento.statusDate = DateTime.Now;

                    XmlNodeList nodeList = xml.GetElementsByTagName("status");
                    oPagSeguroPagamento.status = nodeList[0].InnerText;

                    nodeList = xml.GetElementsByTagName("code");
                    oPagSeguroPagamento.code = nodeList[0].InnerText;

                    nodeList = xml.GetElementsByTagName("paymentMethod")[0].SelectNodes("type");
                    oPagSeguroPagamento.formaPagamento = nodeList[0].InnerText;

                    List <tf_pagseguro_pagamento> lst = db.tf_pagseguro_pagamento.Where(x => (x.codeResponse == oPagSeguroPagamento.code)).ToList <tf_pagseguro_pagamento>();

                    if (lst.Count == 0)
                    {
                        return(false);
                    }

                    lst[0].statusDate     = DateTime.Now;
                    lst[0].status         = GetStatus(oPagSeguroPagamento.status);
                    lst[0].formaPagamento = GetPaymentMethod(oPagSeguroPagamento.formaPagamento);

                    db.SaveChanges();
                    return(true);
                }
            }
            return(true);
        }
Beispiel #2
0
        private void SalvaDados(List <PoupancaItem> lstDataProcessada)
        {
            try
            {
                lstDataProcessada.ForEach(x =>
                {
                    if (this.ultimoAporte < x.aporte)
                    {
                        tf_poupanca poupanca = new tf_poupanca()
                        {
                            aporte     = x.aporte,
                            rendimento = (decimal)x.rendimento
                        };

                        db.tf_poupanca.Add(poupanca);
                        db.SaveChanges();
                    }
                });
            }
            catch (Exception e)
            {
                ErroHandler.Log("HunterPoupanca", e, "SalvaDados", "");
                throw e;
            }
        }
Beispiel #3
0
        private void SalvaDados(List <TesouroDiretoItem> lstDataProcessada)
        {
            try
            {
                lstDataProcessada.ForEach(x =>
                {
                    tf_tesouro tesouro = new tf_tesouro()
                    {
                        loggedTime    = AtualImport,
                        precoUnitario = (decimal)x.precoUnitario,
                        rendimento    = (decimal)x.rendimento,
                        titulo        = x.titulo,
                        valorMinimo   = (decimal)x.valorMinimo,
                        vencimento    = x.vencimento,
                        tipoOperacao  = x.tipoOperacao,
                    };

                    db.tf_tesouro.Add(tesouro);
                    db.SaveChanges();
                });
            }
            catch (Exception e)
            {
                ErroHandler.Log("HunterTesouro", e, "SalvaDados", "");
                throw e;
            }
        }
Beispiel #4
0
        public bool Post([FromBody] dynamic value)
        {
            string nome = value.nome.ToString();

            try
            {
                tf_instituicao inst = new Instituicao().Add(value.nome.ToString(), value.documento.ToString(), value.telefone.ToString(), value.email.ToString());

                new Usuario().Add(value.login.ToString(), value.senha.ToString(), true, inst.id);


                new TipoMovimentacao().Add("Alimentação", inst.id);
                new TipoMovimentacao().Add("Educação", inst.id);
                new TipoMovimentacao().Add("Estéticos", inst.id);
                new TipoMovimentacao().Add("Habitação", inst.id);
                new TipoMovimentacao().Add("Impostos", inst.id);
                new TipoMovimentacao().Add("Lazer", inst.id);
                new TipoMovimentacao().Add("Saúde", inst.id);
                new TipoMovimentacao().Add("Transporte", inst.id);
                new TipoMovimentacao().Add("Vestuário", inst.id);
                new TipoMovimentacao().Add("Outros", inst.id);

                TipoPagamento _TipoPagamento = new TipoPagamento();
                _TipoPagamento.id_instituicao = inst.id;
                _TipoPagamento.is_ativo       = true;

                _TipoPagamento.nome = "Cartão de Crédito";
                new TipoPagamento().Add(_TipoPagamento);

                _TipoPagamento.nome = "Cartão de Débito";
                new TipoPagamento().Add(_TipoPagamento);

                _TipoPagamento.nome = "Dinheiro";
                new TipoPagamento().Add(_TipoPagamento);

                return(true);
            }
            catch (Exception e)
            {
                ErroHandler.Log("Adicionar_EstrelaController", e, "POST", "");

                u2xMainEntities1      db             = new u2xMainEntities1();
                List <tf_instituicao> lstInstituicao = db.tf_instituicao.Where(inst => (inst.nome == nome)).ToList <tf_instituicao>();
                if (lstInstituicao != null && lstInstituicao.Count > 0)
                {
                    db.tf_instituicao.Remove(lstInstituicao[0]);
                    db.SaveChanges();
                }
                throw (e);
            }
        }