//Telefone public EntidadeTelefone EntidadeTelefoneAdicionar(EntidadeTelefone entidadeTelefone) { //if (!entidadeTelefone.IsValid()) // return entidadeTelefone; _entidadeTelefoneRepository.Add(entidadeTelefone); return(entidadeTelefone); }
public List <EntidadeTelefone> ListarTelefonesPorIdPessoa(int id) { string link = "select id, ddd, numero, idPessoa from Telefone where idPessoa = @id"; try { conectar.Conectar(); SqlCommand com = new SqlCommand(link, conectar.con); com.Parameters.AddWithValue("@id", id); SqlDataReader dr = com.ExecuteReader(); List <EntidadeTelefone> lista = new List <EntidadeTelefone>(); EntidadeTelefone tel = null; while (dr.Read()) { tel = new EntidadeTelefone(); tel.Id = Convert.ToInt32(dr["Id"]); tel.DDD = dr["DDD"].ToString(); tel.Numero = dr["Numero"].ToString(); tel.IdPessoa = Convert.ToInt32(dr["IdPessoa"]); lista.Add(tel); } return(lista); } catch (Exception ex) { throw new Exception(ex.Message); } finally { conectar.Desconectar(); } }
public Int32 SalvarContato(EntidadeTelefone t) { string link = @"insert into Telefone values(@ddd, @numero, @id)"; try { conectar.Conectar(); SqlCommand com = new SqlCommand(link, conectar.con); com.Parameters.AddWithValue("@ddd", t.DDD); com.Parameters.AddWithValue("@numero", t.Numero); com.Parameters.AddWithValue("@id", t.IdPessoa); Int32 salvar = Convert.ToInt32(com.ExecuteScalar()); return(salvar); } catch (Exception ex) { throw new Exception(ex.Message); } finally { conectar.Desconectar(); } }
public EntidadeTelefone EntidadeTelefoneAtualizar(EntidadeTelefone entidadeTelefone) { return(_entidadeTelefoneRepository.Update(entidadeTelefone)); }