public IHttpActionResult ConsultPacientes(ConsultPacientModel model) { if (!ModelState.IsValid) { return BadRequest(ModelState); } string value = model.Value; //System.Diagnostics.Debug.Write("entra, value: " + value); int entero; List<ConsultPacientOutputModel> pacientes = new List<ConsultPacientOutputModel>(); if (int.TryParse(value, out entero)) { pacientes = db.Database.SqlQuery<ConsultPacientOutputModel>( "SELECT \"Id\", CONCAT_WS(' ', \"Name\", \"LastName\") as FullName, \"Nit\" FROM dbo.\"Pacientes\" WHERE \"Nit\" ILIKE {0}", "%" + value + "%").ToList(); } else { pacientes = db.Database.SqlQuery<ConsultPacientOutputModel>( "SELECT \"Id\", CONCAT_WS(' ', \"Name\", \"LastName\") as FullName, \"Nit\" FROM dbo.\"Pacientes\" WHERE CONCAT_WS(' ', \"Name\", \"LastName\") ILIKE {0}", "%" + value + "%").ToList(); } return Ok(pacientes); }
public IHttpActionResult PostPaciente(ConsultPacientModel model) { Pacientes pacientes = db.Pacientes.SingleOrDefault(e => e.Nit == model.Value); if (pacientes == null || pacientes.Equals("")) { return NotFound(); } return Ok(pacientes); }