public static User GetUserFromUserNameAndPassword(string userName, string password)
{
using (SqlConnection connection = ConnectionManager.GetConnection())
{
var data = new ActivEarthDataProvidersDataContext(connection);
var toReturn =
(from u in data.UserDataProviders
join p in data.ProfileDataProviders on u.id equals p.user_id
where u.user_name == userName && u.password == password
select
new User
{
UserName = u.user_name,
UserID = u.id,
Email = p.email,
FirstName = p.first_name,
LastName = p.last_name,
City = p.city,
State = p.state,
Gender = p.gender,
ProfileID = p.id,
Age = p.age,
Weight = p.weight,
Height = p.height,
GreenScore = p.green_score,
ActivityScore = new ActivityScore(
p.activity_score_badges,
p.activity_score_challenges,
p.activity_score_contests)
}).FirstOrDefault();
if (toReturn != null)
{
RecentActivityDAO.GetUserRecentActivity(toReturn);
UserStatisticDAO.GetAllStatisticsByUserId(toReturn.UserID).ToDictionary(k => k.Statistic, e => e);
}
return toReturn;
}
}