internal void Check(int id, int socio) { try { using (avrasContext contexto = new avrasContext()) { SociedadeTempo verifica = contexto.SociedadeTempo.Where(p => p.PessoaId == id).Where(p => p.DataFim == null).FirstOrDefault(); if (verifica == null && socio == 1) { verifica = new SociedadeTempo(); verifica.DataInicio = DateTime.Now; verifica.PessoaId = id; contexto.SociedadeTempo.Add(verifica); } if (verifica != null && socio == 0) { verifica.DataFim = DateTime.Now; contexto.SociedadeTempo.Attach(verifica); } contexto.SaveChanges(); } } catch (Exception ex) { } }
internal int Gravar(SociedadeTempo ts) { try { using (avrasContext contexto = new avrasContext()) { int ret = 0; SociedadeTempo Verifica = contexto.SociedadeTempo.Where(p => p.PessoaId == ts.PessoaId).Where(p => p.DataFim == null).FirstOrDefault(); if (Verifica == null) { contexto.SociedadeTempo.Add(ts); contexto.SaveChanges(); return(90); } else if (Verifica != null && ts.DataFim != null) { contexto.SociedadeTempo.Add(ts); return(contexto.SaveChanges()); } else { return(-99); } } } catch (Exception ex) { return(-1); } }
internal int Excluir(int id) { try { using (avrasContext contexto = new avrasContext()) { var pessoa = contexto.Pessoa.Include("Endereco").Where(p => p.Id == id).FirstOrDefault(); if (pessoa != null) { var endereco = pessoa.Endereco; contexto.Endereco.Remove(endereco); contexto.Pessoa.Remove(pessoa); return(contexto.SaveChanges()); } else { return(0); } } } catch { return(-1); } }
internal List <Pessoa> BuscarPessoa(int tipo) { try { using (avrasContext contexto = new avrasContext()) { if (tipo == 1) { return(contexto.Pessoa.OrderBy(p => p.Nome).ToList()); } if (tipo == 2) { byte t = 1; return(contexto.Pessoa.Include("Endereco").Where(p => p.Socio == t).ToList()); } else { byte t = 1; return(contexto.Pessoa.Include("Endereco").Where(p => p.Jogador == t).ToList()); } } } catch (Exception ex) { return(null); } }
internal int Alterar(Patrimonio pAlterado) { try { using (avrasContext contexto = new avrasContext()) { var pAtual = contexto.Patrimonio.Where(p => p.Id == pAlterado.Id).Include("TipoPatrimonio").FirstOrDefault(); pAtual.Nome = pAlterado.Nome; pAtual.Descricao = pAlterado.Descricao; pAtual.Quantidade = pAlterado.Quantidade; pAtual.ValorCompra = pAlterado.ValorCompra; pAtual.ValorPerda = pAlterado.ValorPerda; pAtual.Disponibilidade = pAlterado.Disponibilidade; pAtual.Anotacao = pAlterado.Anotacao; pAtual.DataAquisicao = pAlterado.DataAquisicao; pAtual.DataPerda = pAlterado.DataPerda; pAtual.TipoPatrimonioId = pAlterado.TipoPatrimonioId; return(contexto.SaveChanges()); } } catch (Exception ex) { return(-1); } }
internal int Alterar(Produto palterado) { try { using (avrasContext contexto = new avrasContext()) { var patual = contexto.Produto.Where(p => p.Id == palterado.Id).FirstOrDefault(); patual.Nome = palterado.Nome; patual.ValorVenda = palterado.ValorVenda; patual.Estoque = palterado.Estoque; patual.EstoqueMinimo = palterado.EstoqueMinimo; patual.CategoriaId = palterado.CategoriaId; patual.Disponível = palterado.Disponível; return(contexto.SaveChanges()); } } catch (Exception ex) { return(-1); } }
internal Pessoa BuscarPessoaPorId(int id) { try { using (avrasContext contexto = new avrasContext()) { return(contexto.Pessoa.Find(id)); } } catch (Exception ex) { return(null); } }
internal List <Patrocinadores> BuscarPatrocinadores() { try { using (avrasContext contexto = new avrasContext()) { return(contexto.Patrocinadores.OrderBy(p => p.Nome).ToList()); } } catch (Exception ex) { return(null); } }
internal TipoProduto BuscarCategoriaPorId(int id) { try { using (avrasContext contexto = new avrasContext()) { return(contexto.TipoProduto.Find(id)); } } catch (Exception ex) { return(null); } }
internal List <ContaCorrente> BuscarContaCorrente() { try { using (avrasContext contexto = new avrasContext()) { return(contexto.ContaCorrente.OrderBy(p => p.Valor).ToList()); } } catch (Exception ex) { return(null); } }
internal ContaCorrente BuscarContaCorrentePorId(int id) { try { using (avrasContext contexto = new avrasContext()) { return(contexto.ContaCorrente.Find(id)); } } catch (Exception ex) { return(null); } }
internal List <SociedadeTempo> BuscarSociedadeTempo(int id) { try { using (avrasContext contexto = new avrasContext()) { return(contexto.SociedadeTempo.Include("Pessoa").Where(p => p.PessoaId == id).ToList()); } } catch (Exception ex) { return(null); } }
internal List <TipoProduto> BuscarCategorias() { try { using (avrasContext contexto = new avrasContext()) { return(contexto.TipoProduto.OrderBy(p => p.Nome).ToList()); } } catch (Exception ex) { return(null); } }
internal Patrocinadores BuscarPatrocinadoresPorId(int id) { try { using (avrasContext contexto = new avrasContext()) { return(contexto.Patrocinadores.Find(id)); } } catch (Exception ex) { return(null); } }
internal Produto BuscarProdutosPorId(int id) { try { using (avrasContext contexto = new avrasContext()) { return(contexto.Produto.Find(id)); } } catch (Exception ex) { return(null); } }
internal List <TipoPatrimonio> BuscarTipoPatrimonio() { try { using (avrasContext contexto = new avrasContext()) { return(contexto.TipoPatrimonio.OrderBy(p => p.Nome).ToList()); } } catch (Exception ex) { return(null); } }
internal TipoPatrimonio BuscarTipoPatrimonioPorId(int id) { try { using (avrasContext contexto = new avrasContext()) { return(contexto.TipoPatrimonio.Find(id)); } } catch (Exception ex) { return(null); } }
internal TipoAluguel BuscarTipoAluguelPorId(int id) { try { using (avrasContext contexto = new avrasContext()) { return(contexto.TipoAluguel.Find(id)); } } catch (Exception ex) { return(null); } }
internal Pessoa Autenticar(string email, string senha) { try { using (avrasContext contexto = new avrasContext()) { return((from p in contexto.Pessoa where p.Email == email && p.Senha == senha select p).FirstOrDefault()); } } catch (Exception ex) { return(null); } }
internal Pessoa BuscarPorCpf(string cpf) { try { using (avrasContext contexto = new avrasContext()) { return((from p in contexto.Pessoa where p.Cpf == cpf select p).FirstOrDefault()); } } catch (Exception ex) { return(null); } }
internal int Alterar(ContaCorrente ccAlterado) { try { using (avrasContext contexto = new avrasContext()) { var ccAtual = contexto.ContaCorrente.Where(p => p.Id == ccAlterado.Id).FirstOrDefault(); ccAtual.Valor = ccAlterado.Valor; return(contexto.SaveChanges()); } } catch (Exception ex) { return(-1); } }
internal Endereco BuscarEnderecoPorId(int id) { try { using (avrasContext contexto = new avrasContext()) { return((from e in contexto.Endereco where e.PessoaId == id select e).FirstOrDefault()); } } catch (Exception ex) { return(null); } }
internal int Change(int id) { try { using (avrasContext contexto = new avrasContext()) { Pessoa pes = contexto.Pessoa.Find(id); pes.Socio = 1; contexto.Pessoa.Attach(pes); return(contexto.SaveChanges()); } } catch (Exception ex) { return(0); } }
internal int Alterar(TipoProduto ptAlterado) { try { using (avrasContext contexto = new avrasContext()) { var pAtual = contexto.TipoProduto.Where(p => p.Id == ptAlterado.Id).FirstOrDefault(); pAtual.Nome = ptAlterado.Nome; pAtual.SrcImagem = ptAlterado.SrcImagem; return(contexto.SaveChanges()); } } catch (Exception ex) { return(-1); } }
internal int Alterar(TipoAluguel taAlterado) { try { using (avrasContext contexto = new avrasContext()) { var tpAtual = contexto.TipoAluguel.Where(p => p.Id == taAlterado.Id).FirstOrDefault(); tpAtual.Nome = taAlterado.Nome; tpAtual.Valor = taAlterado.Valor; return(contexto.SaveChanges()); } } catch (Exception ex) { return(-1); } }
internal int Alterar(TipoPatrimonio tpAlterado) { try { using (avrasContext contexto = new avrasContext()) { var tpAtual = contexto.TipoPatrimonio.Where(p => p.Id == tpAlterado.Id).FirstOrDefault(); tpAtual.Nome = tpAlterado.Nome; tpAtual.Descricao = tpAlterado.Descricao; return(contexto.SaveChanges()); } } catch (Exception ex) { return(-1); } }
internal List <Patrocinadores> BuscarPatrocinadoresPorNome(string nome) { try { using (avrasContext contexto = new avrasContext()) { nome = "%" + nome + "%"; return((from p in contexto.Patrocinadores where EF.Functions.Like(p.Nome, nome) select p).ToList()); } } catch (Exception ex) { return(null); } }
public int TrocarSenha(string email, string senha, string senhaNova) { try { using (avrasContext contexto = new avrasContext()) { Pessoa pes = (from p in contexto.Pessoa where p.Email == email && p.Senha == senha select p).FirstOrDefault(); pes.Senha = senhaNova; contexto.Attach(pes); return(contexto.SaveChanges()); } } catch (Exception ex) { return(0); } }
internal int Alterar(Patrocinadores pAlterado) { try { using (avrasContext contexto = new avrasContext()) { var pAtual = contexto.Patrocinadores.Where(p => p.Id == pAlterado.Id).FirstOrDefault(); pAtual.Nome = pAlterado.Nome; pAtual.DataCadastro = pAlterado.DataCadastro; pAtual.Valor = pAlterado.Valor; pAtual.Parcelas = pAlterado.Parcelas; return(contexto.SaveChanges()); } } catch (Exception ex) { return(-1); } }
internal int Alterar(Pessoa pAlterado) { try { using (avrasContext contexto = new avrasContext()) { var pAtual = contexto.Pessoa.Where(p => p.Id == pAlterado.Id).Include("Endereco").FirstOrDefault(); pAtual.Nome = pAlterado.Nome; pAtual.DataNascimento = pAlterado.DataNascimento; pAtual.Email = pAlterado.Email; pAtual.Telefone = pAlterado.Telefone; if (pAlterado.Senha != null) { pAtual.Senha = pAlterado.Senha; } if (pAlterado.PendenciaId != null) { pAtual.PendenciaId = pAlterado.PendenciaId; } pAtual.Socio = pAlterado.Socio; pAtual.Jogador = pAlterado.Jogador; pAtual.Isento = pAlterado.Isento; if (pAlterado.Observacoes != null) { pAtual.Observacoes = pAlterado.Observacoes; } pAtual.Endereco.Cep = pAlterado.Endereco.Cep; pAtual.Endereco.Cidade = pAlterado.Endereco.Cidade; pAtual.Endereco.Bairro = pAlterado.Endereco.Bairro; pAtual.Endereco.Rua = pAlterado.Endereco.Rua; pAtual.Endereco.Numero = pAlterado.Endereco.Numero; pAtual.Endereco.Complemento = pAlterado.Endereco.Complemento; return(contexto.SaveChanges()); } } catch (Exception ex) { return(-1); } }