Example #1
0
        public void ExcluirCliente(string numeroCartao)
        {
            StoneEntities db   = new StoneEntities();
            Card          card = db.Card.FirstOrDefault(f => f.Number == numeroCartao);

            if (card != null)
            {
                db.Transaction.RemoveRange(card.Transaction);
                db.Client.Remove(card.Client);
                db.Card.Remove(card);
            }
            db.SaveChanges();
        }
Example #2
0
        public AuthenticateDTO Authencticate(string numeroCartao, string senha)
        {
            StoneEntities db = new StoneEntities();

            Card card = db.Card.FirstOrDefault(f => f.Number == numeroCartao);

            if (card != null)
            {
                RetornoTransacao retornoTransacao = card.ValidarSenha(senha);
                db.SaveChanges();
                return(new AuthenticateDTO(retornoTransacao, retornoTransacao == RetornoTransacao.AUTENTICADO ? card.guid : null));
            }


            return(new AuthenticateDTO(RetornoTransacao.TRANSACAO_NEGADA, null));
        }
Example #3
0
 public RetornoTransacao RealizarTransacao(string cartao, decimal valor, int tipo, int parcelas, string guid)
 {
     try
     {
         StoneEntities db   = new StoneEntities();
         Card          card = db.Card.FirstOrDefault(f => f.Number == cartao);
         if (card != null)
         {
             RetornoTransacao retorno = card.ValidarTransacao(valor, tipo, parcelas, guid);
             if (retorno == RetornoTransacao.APROVADO)
             {
                 db.SaveChanges();
             }
             return(retorno);
         }
         return(RetornoTransacao.TRANSACAO_NEGADA);
     }
     catch
     {
         return(RetornoTransacao.TRANSACAO_NEGADA);
     }
 }
Example #4
0
        public void SalvarCliente(string numeroCartao, string nome, string bandeira, decimal saldo, string senha, int tipo)
        {
            StoneEntities db   = new StoneEntities();
            Card          card = db.Card.FirstOrDefault(f => f.Number == numeroCartao);

            if (card == null)
            {
                db.Card.Add(new Card
                {
                    ExpirationDate = DateTime.Now.Date.AddYears(13),
                    CardBrand      = bandeira,
                    Type           = tipo,
                    HasPassword    = tipo == 1,
                    CardHolderName = nome,
                    Number         = numeroCartao,
                    Password       = senha.GerarHashMd5(),
                    Client         = new Client
                    {
                        Nome  = nome,
                        Saldo = saldo
                    }
                });
                db.SaveChanges();
            }
            else
            {
                card.ExpirationDate = DateTime.Now.Date.AddYears(13);
                card.CardBrand      = bandeira;
                card.Type           = tipo;
                card.HasPassword    = tipo == 1;
                card.CardHolderName = nome;
                card.Password       = senha.GerarHashMd5();

                card.Client.Nome  = nome;
                card.Client.Saldo = saldo;

                db.SaveChanges();
            }
        }
Example #5
0
        public IEnumerable <Transaction> GetAll(int?card)
        {
            StoneEntities db = new StoneEntities();

            return(db.Transaction.Where(t => (!card.HasValue || t.CardID == card.Value)).OrderByDescending(f => f.TransactionID));
        }
Example #6
0
        public Card Get(string numeroCartao)
        {
            StoneEntities db = new StoneEntities();

            return(db.Card.FirstOrDefault(f => f.Number == numeroCartao));
        }
Example #7
0
        public IEnumerable <Card> GetAll()
        {
            StoneEntities db = new StoneEntities();

            return(db.Card.OrderBy(f => f.CardHolderName).ToList());
        }