// GET api/login/5 public string Get(string name, string password) { DataConnection connection = new DataConnection("localhost", "user", "root", "testing"); MySqlDataReader dr = connection.GetAll("users"); while (dr.Read()) { if ((string)dr["name"] == name && (string)dr["password"] == password) { connection.Close(); return "Successful login"; } } connection.Close(); return "Wrong name or password"; }
// GET api/login public IEnumerable<User> Get() { List<User> list = new List<User>(); DataConnection connection = new DataConnection("localhost", "user", "root", "testing"); MySqlDataReader dr = connection.GetAll("users"); while (dr.Read()) { User p = new User(); p.Name = dr["name"].ToString(); p.Password = "******"; list.Add(p); } connection.Close(); return list.ToArray(); }
// GET api/patient public IEnumerable<Patient> Get() { List<Patient> list = new List<Patient>(); DataConnection connection = new DataConnection("localhost", "health", "root", "testing"); MySqlDataReader dr = connection.GetAll("patients"); while (dr.Read()) { Patient p = new Patient(); p.id = int.Parse(dr["id"].ToString()); p.name = dr["name"].ToString(); p.surname = dr["surname"].ToString(); p.telephonenumber = dr["telephonenumber"].ToString(); list.Add(p); } connection.Close(); return list.ToArray(); }