public static bool ValidaTelefone(int ddd, string telefone) { if (Telefone.IsValidDdd(ddd) && telefone != string.Empty) { return(true); } else { return(false); } }
public static Telefone TrataTelefone(int tipo, int ddd, string numero) { if (Telefone.IsValidDdd(ddd)) { if (numero != string.Empty) { return(new Telefone() { Tipo = tipo, Ddd = ddd, Numero = numero }); } else { throw new NewUserFailedException("DDD preenchido, porém número de telefone não preenchido."); } } else { throw new NewUserFailedException("DDD inválido."); } }