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(); }
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)); }
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); } }
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(); } }
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)); }
public Card Get(string numeroCartao) { StoneEntities db = new StoneEntities(); return(db.Card.FirstOrDefault(f => f.Number == numeroCartao)); }
public IEnumerable <Card> GetAll() { StoneEntities db = new StoneEntities(); return(db.Card.OrderBy(f => f.CardHolderName).ToList()); }