public bool AddUser2(RequestData rData) { bool returnBool = false; var data = rData.details.Split('|'); var response = new PersonData { Name = data[0], User = data[1], Email = data[2], Password = data[3] }; SqlConnection dbConn = new SqlConnection(connStr); string sqlStr = "INSERT INTO users(username,name,email,password) values('" + data[0] + "', '" + data[1] + "', '" + data[2] + "', '" + data[3] + "');"; SqlCommand dbCommand = new SqlCommand(sqlStr, dbConn); try { dbConn.Open(); if (dbCommand.ExecuteNonQuery() != 0) { returnBool = true; } returnBool = true; } catch { returnBool = false; } dbConn.Close(); return returnBool; }
public bool UpdateUserPut(string user, RequestData rData) { bool returnBool = false; var data = rData.details.Split('|'); var pd = new PersonData { Name = data[0], User = data[1], Email = data[2], Password = data[3] }; string username, name, email, password; username = pd.User; name = pd.Name; email = pd.Email; password = pd.Password; SqlConnection dbConn = new SqlConnection(connStr); string sqlStr = "UPDATE users SET username = '******',name = '" + name + "',password = '******',email= '" + email + "' WHERE username = '******' ;"; SqlCommand dbCommand = new SqlCommand(sqlStr, dbConn); try { dbConn.Open(); if (dbCommand.ExecuteNonQuery() != 0) { returnBool = true; } dbConn.Close(); } catch { returnBool = false; } return returnBool; }
public PersonData AddJsonUser(RequestData rData) { return AddUser(rData); }