public override void UpdateProfile(AuthorProfile profile)
{
// Remove Profile
this.DeleteProfile(profile);
// Create Profile Dictionary
var dic = new StringDictionary();
if (!String.IsNullOrEmpty(profile.DisplayName))
{
dic.Add("DisplayName", profile.DisplayName);
}
if (!String.IsNullOrEmpty(profile.FirstName))
{
dic.Add("FirstName", profile.FirstName);
}
if (!String.IsNullOrEmpty(profile.MiddleName))
{
dic.Add("MiddleName", profile.MiddleName);
}
if (!String.IsNullOrEmpty(profile.LastName))
{
dic.Add("LastName", profile.LastName);
}
if (!String.IsNullOrEmpty(profile.CityTown))
{
dic.Add("CityTown", profile.CityTown);
}
if (!String.IsNullOrEmpty(profile.RegionState))
{
dic.Add("RegionState", profile.RegionState);
}
if (!String.IsNullOrEmpty(profile.Country))
{
dic.Add("Country", profile.Country);
}
if (!String.IsNullOrEmpty(profile.AboutMe))
{
dic.Add("AboutMe", profile.AboutMe);
}
if (!String.IsNullOrEmpty(profile.PhotoUrl))
{
dic.Add("PhotoURL", profile.PhotoUrl);
}
if (!String.IsNullOrEmpty(profile.Company))
{
dic.Add("Company", profile.Company);
}
if (!String.IsNullOrEmpty(profile.EmailAddress))
{
dic.Add("EmailAddress", profile.EmailAddress);
}
if (!String.IsNullOrEmpty(profile.PhoneMain))
{
dic.Add("PhoneMain", profile.PhoneMain);
}
if (!String.IsNullOrEmpty(profile.PhoneMobile))
{
dic.Add("PhoneMobile", profile.PhoneMobile);
}
if (!String.IsNullOrEmpty(profile.PhoneFax))
{
dic.Add("PhoneFax", profile.PhoneFax);
}
if (profile.Birthday != DateTime.MinValue)
{
dic.Add("Birthday", profile.Birthday.ToString("yyyy-MM-dd"));
}
dic.Add("IsPrivate", profile.Private.ToString());
// Save Profile Dictionary
using (var conn = this.CreateConnection())
{
using (var cmd = conn.CreateCommand())
{
foreach (string key in dic.Keys)
{
var sqlQuery = string.Format("INSERT INTO {0}Profiles (BlogID, UserName, SettingName, SettingValue) VALUES ({1}blogid, {1}user, {1}name, {1}value)", this.tablePrefix, this.parmPrefix);
cmd.CommandText = sqlQuery;
cmd.Parameters.Clear();
cmd.Parameters.Add(conn.CreateParameter(FormatParamName("blogid"), Blog.CurrentInstance.Id.ToString()));
cmd.Parameters.Add(conn.CreateParameter(FormatParamName("user"), profile.Id));
cmd.Parameters.Add(conn.CreateParameter(FormatParamName("name"), key));
cmd.Parameters.Add(conn.CreateParameter(FormatParamName("value"), dic[key]));
cmd.ExecuteNonQuery();
}
}
}
}