Created
June 20, 2011 18:18
-
-
Save einarwh/1036199 to your computer and use it in GitHub Desktop.
Dry data: Final version of the client
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Client5 | |
{ | |
private readonly Database _db; | |
public Client5(Database db) | |
{ | |
_db = db; | |
} | |
public IEnumerable<User> GetCompanyUsers(string company) | |
{ | |
return _db.ExecuteReader( | |
"spGetCompanyUsers", | |
sp => sp["@companyName", company], | |
r => new User | |
{ | |
Id = (string) r["id"], | |
UserName = (string) r["user"], | |
Name = (string) r["name"], | |
Email = (string) r["emailAddress"], | |
Phone = (string) r["cellPhone"], | |
ZipCode = (string) r["zip"] | |
}); | |
} | |
public string GetUserEmail(string userId) | |
{ | |
return _db.ExecuteScalar( | |
"spGetEmailForUser", | |
sp => sp["@userId", userId], | |
o => o as string); | |
} | |
public void StoreUser(User u) | |
{ | |
_db.ExecuteNonQuery( | |
"spInsertOrUpdateUser", | |
sp => sp["@userId", u.Id] | |
["@user", u.UserName] | |
["@name", u.Name] | |
["@emailAddress", u.Email] | |
["@cellPhone", u.Phone] | |
["@zip", u.ZipCode]); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment