private void SetSearchPacienteCommandOutputs(SqlCommand cmd, SearchPacienteOutput output) { if (cmd.Parameters[1].Value != DBNull.Value) { output.ReturnValue = (SearchPacienteOutput.Returns)cmd.Parameters[1].Value; } }
public List <Paciente> GetPaciente(string query) { Service service = new Service(""); SearchPacienteInput input = new SearchPacienteInput() { Searchtext = query }; SearchPacienteOutput listaPacientes = service.SearchPaciente(input); if (listaPacientes.ReturnValue == SearchPacienteOutput.Returns.Ok) { return((from paciente in listaPacientes.ResultData select new Paciente() { Apellido = paciente.Apellido, DNI = paciente.DNI, Domicilio = paciente.Domicilio, FechaNacimiento = paciente.FechaNacimiento.Value, IdPaciente = paciente.IdPaciente, Localidad = paciente.Localidad, Nombre = paciente.Nombre, Sexo = paciente.Sexo, Telefono = paciente.Telefono }).ToList()); } else { return(new List <Paciente>()); } }
public List <Paciente> GetAllPacientes(string filtro) { Service service = GetService(); SearchPacienteInput input = new SearchPacienteInput() { Searchtext = filtro }; SearchPacienteOutput listaPacientes = service.SearchPaciente(input); if (listaPacientes.ReturnValue == SearchPacienteOutput.Returns.Ok) { return((from paciente in listaPacientes.ResultData select new Paciente() { Apellido = paciente.Apellido, DNI = paciente.DNI, Domicilio = paciente.Domicilio, FechaNacimiento = paciente.FechaNacimiento == null ? new DateTime(1800, 1, 1) : paciente.FechaNacimiento, IdPaciente = paciente.IdPaciente, Localidad = paciente.Localidad, Nombre = paciente.Nombre, Sexo = paciente.Sexo, Telefono = paciente.Telefono }).ToList()); } else { return(new List <Paciente>()); } }
/// <summary> /// Search for coincidences on Nombre, Apellido, DNI y Telefono. /// SQL+ Routine: dbo.SearchPaciente - Authored by IStrficek /// </summary> public SearchPacienteOutput SearchPaciente(ISearchPacienteInput input) { if (!input.IsValid()) { throw new ArgumentException("SearchPacienteInput fails validation - use the SearchPacienteInput.IsValid() method prior to passing the input argument to the SearchPaciente method.", "input"); } SearchPacienteOutput output = new SearchPacienteOutput(); if (sqlConnection != null) { using (SqlCommand cmd = GetSearchPacienteCommand(sqlConnection, input)) { cmd.Transaction = sqlTransaction; SearchPacienteCommand(cmd, output); } return(output); } for (int idx = 0; idx <= retryOptions.RetryIntervals.Count; idx++) { if (idx > 0) { System.Threading.Thread.Sleep(retryOptions.RetryIntervals[idx - 1]); } try { using (SqlConnection cnn = new SqlConnection(connectionString)) using (SqlCommand cmd = GetSearchPacienteCommand(cnn, input)) { cnn.Open(); SearchPacienteCommand(cmd, output); cnn.Close(); } break; } catch (SqlException sqlException) { bool throwException = true; if (retryOptions.TransientErrorNumbers.Contains(sqlException.Number)) { throwException = (idx == retryOptions.RetryIntervals.Count); if (retryOptions.Logger != null) { retryOptions.Logger.Log(sqlException); } } if (throwException) { throw; } } } return(output); }
private void SearchPacienteCommand(SqlCommand cmd, SearchPacienteOutput output) { using (SqlDataReader rdr = cmd.ExecuteReader()) { output.ResultData = new List <SearchPacienteResult>(); while (rdr.Read()) { output.ResultData.Add(GetSearchPacienteResultFromReader(rdr)); } rdr.Close(); } SetSearchPacienteCommandOutputs(cmd, output); }