public static bool UpdateUserProfile(User user)
{
try
{
using (SqlConnection connection = ConnectionManager.GetConnection())
{
var data = new ActivEarthDataProvidersDataContext(connection);
ProfileDataProvider profile =
(from p in data.ProfileDataProviders where p.user_id == user.UserID select p).FirstOrDefault();
if (profile != null)
{
profile.first_name = user.FirstName;
profile.last_name = user.LastName;
profile.gender = user.Gender;
profile.city = user.City;
profile.state = user.State;
profile.email = user.Email;
profile.age = user.Age;
profile.height = user.Height;
profile.weight = user.Weight;
profile.green_score = user.GreenScore;
if (user.ActivityScore != null)
{
profile.activity_score_badges = user.ActivityScore.BadgeScore;
profile.activity_score_challenges = user.ActivityScore.ChallengeScore;
profile.activity_score_contests = user.ActivityScore.ContestScore;
}
RecentActivityDAO.UpdateUserRecentActivity(user);
data.SubmitChanges();
return true;
}
else
{
return false;
}
}
}
catch (Exception)
{
return false;
}
}