Skip to content

Commit

Permalink
get customer is now half done
Browse files Browse the repository at this point in the history
  • Loading branch information
Jeremy Mill committed Nov 11, 2015
1 parent 7d29614 commit ccc7644
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
7 changes: 5 additions & 2 deletions TeamDBAwesome/TeamDBAwesome/Controllers/TestController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,15 @@ public HttpResponseMessage Get()
test.Phone = "9109153999";
test.Post = "06066";
test.State = "CT";
test.SupportRepId = 1;
test.SupportRepId = 0;

//make an instance of the sql controller
MySqlService sqlS = new MySqlService();
//try and add the new user
int ID = sqlS.AddNewUser(test);
//int ID = sqlS.AddNewUser(test);
int ID = 0;

Customer customer = sqlS.GetCustomer(3);



Expand Down
17 changes: 17 additions & 0 deletions TeamDBAwesome/TeamDBAwesome/SqlService/MySqlService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,19 @@ public Customer GetCustomer(int PersonID)

if(open == true)
{
string customer_query = "select * from `person` left join `customer` on person.PersonId=customer.PersonID where Customer.CustomerID = "+PersonID.ToString();
MySqlCommand cmd = new MySqlCommand(customer_query, SqlConn);

MySqlDataReader reader = cmd.ExecuteReader();

while(reader.Read())
{
customer.FName = GetDBString("FirstName", reader);
customer.LName = GetDBString("LastName", reader);
customer.CustomerID = int.Parse(GetDBString("CutomerID", reader));
}


return customer;
}
else
Expand All @@ -142,5 +155,9 @@ public Customer GetCustomer(int PersonID)
}

}
private string GetDBString(string SqlFieldName, MySqlDataReader Reader)
{
return Reader[SqlFieldName].Equals(DBNull.Value) ? String.Empty : Reader.GetString(SqlFieldName);
}
}
}

0 comments on commit ccc7644

Please sign in to comment.