// DELETE: api/User/5 public string Delete(string username, string password) { try { return(Authouriser.unsubscribeUser(username, password)); } catch (ArgumentException e) { return(e.Message); } }
// GET: api/User/5 public Authouriser Get(string username) { try { return(Authouriser.getUserCreditials(username)); } catch (ArgumentException e) { Debug.WriteLine(e.Message); return(null); } }
// GET: api/User public List <Authouriser> Get() { try { return(Authouriser.getAllUsersCreditials()); } catch (ArgumentException e) { Debug.WriteLine(e.Message); return(null); } }
// PUT: api/User/5 public string Put([FromBody] Authouriser authouriser) { string username = authouriser.Username; string password = authouriser.Password; try { return(Authouriser.resetUserCreditials(username, password)); } catch (ArgumentException e) { return(e.Message); } }
// POST: api/User public string Post([FromBody] Authouriser authouriser) { string username = authouriser.Username; string password = authouriser.Password; string results = null; try { results = Authouriser.craeteCreditials(username, password); } catch (Exception e) { results = e.Message; } return(results); }
// Get single user by Id public Authouriser getUserFromTheDatabase(string username) { Authouriser results = new Authouriser(); string connectinString = ConfigurationManager.ConnectionStrings["DBCS"].ConnectionString; string query = string.Format("SELECT [Id],[Username],[Password],[Role] FROM tblAuthouriser WHERE [Username] = '{0}'", username); using (SqlConnection conn = new SqlConnection(connectinString)) { using (SqlCommand com = new SqlCommand(query, conn)) { conn.Open(); SqlDataReader reader = com.ExecuteReader(); while (reader.Read()) { results.Id = (int)reader["Id"]; results.Username = (string)reader["Username"]; results.Password = (string)reader["Password"]; results.Role = (string)reader["Role"]; } conn.Close(); } } return(results); }