GetUserStatistic() public method

Gets a statistic for a user based on the statistic type.
public GetUserStatistic ( Statistic statToGet ) : UserStatistic
statToGet Statistic Statistic to retrieve.
return ActivEarth.Objects.Profile.UserStatistic
Example #1
0
        /// <summary>
        /// Prepares the display of the User's Image, Name, Recent Activity, Weather information, and Statistics
        /// when the page loads.
        /// </summary>
        protected void Page_Load(object sender, EventArgs e)
        {
            // if user is not logged in
            if (Session["userDetails"] == null)
            {
                lbLogOut.Visible = false;
                lblUserLoggedIn.Visible = false;
            }
            else
            {
                var userDetails = (User) Session["userDetails"];
                hlRegister.Visible = false;
                hlLogin.Visible = false;
                lbLogOut.Visible = true;
                lblUserLoggedIn.Visible = true;
                lblUserLoggedIn.Text = "Logged in as " + userDetails.UserName;

                lblUserName.Text = userDetails.FirstName + " " + userDetails.LastName;
                userIconImage.ImageUrl = getUserImageUrl(userDetails, "icon");

                List<Message> messages = userDetails.Wall.Messages;
                Color[] backColors = {Color.White, Color.FromArgb(34, 139, 34)};
                Color[] textColors = {Color.Black, Color.White };
                RecentActivityTable.PopulateMessageTable(messages, backColors, textColors);

                lblActivityScore.Text = userDetails.ActivityScore.TotalScore.ToString();
                lblGreenScore.Text = userDetails.GreenScore.ToString();
                StatisticManager userStat = new StatisticManager(userDetails);
                lblStatGasSavings.Text = "$ " + userStat.GetUserStatistic(Statistic.GasSavings).Value;

                if (userDetails.City != null)
                {
                    if (DisplayWeatherControl1.GetCurrentConditions(userDetails.City.Replace(' ', '+')))
                    {
                        CityNotFound.Text = "";
                    }
                    else
                    {
                        DisplayWeatherControl1.Visible = false;
                        CityNotFound.Text = "City was not found.  Please edit the city in your profile information to view Weather updates.";
                    }
                }
                else
                {
                    DisplayWeatherControl1.Visible = false ;
                    CityNotFound.Text = "Please enter a city into your profile information to view Weather updates.";
                }
            }
        }