public override AuthorProfile SelectProfile(string id)
{
var dic = new StringDictionary();
var profile = new AuthorProfile(id);
// Retrieve Profile data from Db
using (var conn = this.CreateConnection())
{
if (conn.HasConnection)
{
using (var cmd = conn.CreateTextCommand(string.Format("SELECT SettingName, SettingValue FROM {0}Profiles WHERE BlogID = {1}blogid AND UserName = {1}name", this.tablePrefix, this.parmPrefix)))
{
cmd.Parameters.Add(conn.CreateParameter(FormatParamName("blogid"), Blog.CurrentInstance.Id.ToString()));
cmd.Parameters.Add(conn.CreateParameter(FormatParamName("name"), id));
using (var rdr = cmd.ExecuteReader())
{
while (rdr.Read())
{
dic.Add(rdr.GetString(0), rdr.GetString(1));
}
}
}
}
}
// Load profile with data from dictionary
if (dic.ContainsKey("DisplayName"))
{
profile.DisplayName = dic["DisplayName"];
}
if (dic.ContainsKey("FirstName"))
{
profile.FirstName = dic["FirstName"];
}
if (dic.ContainsKey("MiddleName"))
{
profile.MiddleName = dic["MiddleName"];
}
if (dic.ContainsKey("LastName"))
{
profile.LastName = dic["LastName"];
}
if (dic.ContainsKey("CityTown"))
{
profile.CityTown = dic["CityTown"];
}
if (dic.ContainsKey("RegionState"))
{
profile.RegionState = dic["RegionState"];
}
if (dic.ContainsKey("Country"))
{
profile.Country = dic["Country"];
}
if (dic.ContainsKey("Birthday"))
{
DateTime date;
if (DateTime.TryParse(dic["Birthday"], out date))
{
profile.Birthday = date;
}
}
if (dic.ContainsKey("AboutMe"))
{
profile.AboutMe = dic["AboutMe"];
}
if (dic.ContainsKey("PhotoURL"))
{
profile.PhotoUrl = dic["PhotoURL"];
}
if (dic.ContainsKey("Company"))
{
profile.Company = dic["Company"];
}
if (dic.ContainsKey("EmailAddress"))
{
profile.EmailAddress = dic["EmailAddress"];
}
if (dic.ContainsKey("PhoneMain"))
{
profile.PhoneMain = dic["PhoneMain"];
}
if (dic.ContainsKey("PhoneMobile"))
{
profile.PhoneMobile = dic["PhoneMobile"];
}
if (dic.ContainsKey("PhoneFax"))
{
profile.PhoneFax = dic["PhoneFax"];
}
if (dic.ContainsKey("IsPrivate"))
{
profile.Private = dic["IsPrivate"] == "true";
}
return profile;
}