public endereco selecionarEnderecoComRuaeNumero(string logradouro, int numero) { endereco end = new endereco(); using (ImobGentilEntities db = new ImobGentilEntities()) { end = (from e in db.endereco where e.logradouro.Contains(logradouro) && e.numero == numero orderby e.id descending select e).First(); return(end); } }
public int selecionarUltimoEnderecoID(endereco end) { int id = 0; using (ImobGentilEntities db = new ImobGentilEntities()) { id = (from e in db.endereco where e.logradouro.Contains(end.logradouro) orderby e.id descending select e.id).First(); return(id); } }
public endereco selecionarEnderecoPorID(int id) { endereco end = new endereco(); using (ImobGentilEntities db = new ImobGentilEntities()) { end = (from e in db.endereco where e.id == id select e).First(); } return(end); }
public endereco selecionarEnderecoComIDPessoa(int idpessoa) { endereco end = new endereco(); using (ImobGentilEntities db = new ImobGentilEntities()) { end = (from p in db.pessoa join e in db.endereco on p.idendereco equals e.id where p.id == idpessoa select e).FirstOrDefault(); } return(end); }
public endereco verificarSeEnderecoExiste(int id) { endereco retorno = new endereco(); using (ImobGentilEntities db = new ImobGentilEntities()) { retorno = (from e in db.endereco join p in db.pessoa on e.id equals p.idendereco where p.id == id select e).FirstOrDefault(); } return(retorno); }
public void modificarCorretor(endereco end) { using (ImobGentilEntities db = new ImobGentilEntities()) { try { db.Entry(end).State = System.Data.EntityState.Modified; db.SaveChanges(); } catch (Exception) { //throw; } } }
public void AdicionarEndereco(endereco end) { try { using (ImobGentilEntities db = new ImobGentilEntities()) {//adicionar pessoa e vir com a opção, se a mesma vai ser usuario, cliente ou corretor db.endereco.Add(end); //é necessario adicionar no banco, depois fazer um select ou arranjar uma forma de pegar o ultimo adicionado e adicionar a chave estrangeira no usuario db.SaveChanges(); } } catch (Exception e) { throw e; //MessageBox.Show(e.Message); } }
public void alterarCorretor(pessoa pes, corretor cor, endereco end)//funciona para adicionar o ID em todos { using (ImobGentilEntities db = new ImobGentilEntities()) { try { db.Entry(pes).State = System.Data.EntityState.Modified; db.SaveChanges(); } catch (Exception) { throw; } } using (ImobGentilEntities db = new ImobGentilEntities()) { try { db.Entry(cor).State = System.Data.EntityState.Modified; db.SaveChanges(); } catch (Exception) { throw; } } using (ImobGentilEntities db = new ImobGentilEntities()) { try { db.Entry(end).State = System.Data.EntityState.Modified; db.SaveChanges(); } catch (Exception) { throw; } } }