protected void bAjaxPostback_Click(object sender, EventArgs e)
        {
            string status = string.Empty;

            try
            {
                //Affine.WebService.StreamService ss = new Affine.WebService.StreamService();
                aqufitEntities entities = new aqufitEntities();
                switch (hiddenAjaxAction.Value)
                {
                case "getProfile":
                    // TODO: verify that this person can view stats on the person?
                    UserSettings profile = entities.UserSettings.Include("Metrics").FirstOrDefault(u => u.UserName == hiddenAjaxValue.Value && u.PortalKey == this.PortalId);
                    DotNetNuke.Entities.Users.UserController ucontroller = new UserController();
                    UserInfo ui = ucontroller.GetUser((int)profile.PortalKey, (int)profile.UserKey);
                    Affine.Data.json.UserSetting us = new Affine.Data.json.UserSetting()
                    {
                        Id        = profile.Id,
                        PortalKey = profile.PortalKey,
                        FirstName = profile.UserFirstName,
                        LastName  = profile.UserLastName,
                        UserKey   = profile.UserKey,
                        UserName  = profile.UserName,
                        LatHome   = Convert.ToDouble(profile.LatHome),
                        LngHome   = Convert.ToDouble(profile.LngHome)
                    };
                    us.Metrics = profile.Metrics.Select(m => new Affine.Data.json.Metric()
                    {
                        Id = m.Id, MetricType = m.MetricType, MetricValue = m.MetricValue
                    }).ToArray();
                    WorkoutTotal totals = entities.WorkoutTotals.FirstOrDefault(wt => wt.UserKey == profile.UserKey && wt.PortalKey == profile.PortalKey && wt.WorkoutTypeKey == 0);       // When workout type key == 0 This is the "Entire" totals for all workout types
                    us.Totals = new Data.json.Totals()
                    {
                        Calories = totals.Calories, Count = totals.Count, Distance = totals.Distance, Id = totals.Id
                    };
                    RadAjaxManager1.ResponseScripts.Add("pushProfileToFlex('" + us.ToJson() + "'); ");
                    break;

                case "getWorkout":
                    long    wid     = Convert.ToInt64(hiddenAjaxValue.Value);
                    int     context = Convert.ToInt32(hiddenAjaxContext.Value);
                    Workout wo      = entities.UserStreamSet.OfType <Workout>().Include("WOD").Include("WOD.WODType").Include("WorkoutExtendeds").FirstOrDefault(w => w.Id == wid);
                    LoadFlexDataForWorkout(wo, Utils.ConstsUtil.toGraphContext(context));
                    RadAjaxManager1.ResponseScripts.Add("pushWorkoutToFlex('" + hiddenWorkoutData.Value + "'); ");
                    break;
                }
            }
            catch (Exception ex)
            {
                status = "ERROR: There was a problem with the action (" + ex.Message + ")" + ex.StackTrace;
                RadAjaxManager1.ResponseScripts.Add("alert('" + status.Replace("\r\n", "") + "'); ");
            }
            //RadAjaxManager1.ResponseScripts.Add("UpdateStatus('" + status + "'); ");
        }
 protected void bAjaxPostback_Click(object sender, EventArgs e)
 {
     string status = string.Empty;
     try
     {
         //Affine.WebService.StreamService ss = new Affine.WebService.StreamService();
         aqufitEntities entities = new aqufitEntities();
         switch (hiddenAjaxAction.Value)
         {
             case "getProfile":
                 // TODO: verify that this person can view stats on the person?
                 UserSettings profile = entities.UserSettings.Include("Metrics").FirstOrDefault(u => u.UserName == hiddenAjaxValue.Value && u.PortalKey == this.PortalId);
                 DotNetNuke.Entities.Users.UserController ucontroller = new UserController();
                 UserInfo ui = ucontroller.GetUser((int)profile.PortalKey, (int)profile.UserKey);
                 Affine.Data.json.UserSetting us = new Affine.Data.json.UserSetting()
                 {
                     Id = profile.Id,
                     PortalKey = profile.PortalKey,
                     FirstName = profile.UserFirstName,
                     LastName = profile.UserLastName,
                     UserKey = profile.UserKey,
                     UserName = profile.UserName,
                     LatHome = Convert.ToDouble(profile.LatHome),
                     LngHome = Convert.ToDouble(profile.LngHome)
                 };
                 us.Metrics = profile.Metrics.Select(m => new Affine.Data.json.Metric() { Id = m.Id, MetricType = m.MetricType, MetricValue = m.MetricValue }).ToArray();
                 WorkoutTotal totals = entities.WorkoutTotals.FirstOrDefault(wt => wt.UserKey == profile.UserKey && wt.PortalKey == profile.PortalKey && wt.WorkoutTypeKey == 0);   // When workout type key == 0 This is the "Entire" totals for all workout types
                 us.Totals = new Data.json.Totals() { Calories = totals.Calories, Count = totals.Count, Distance = totals.Distance, Id = totals.Id };
                 RadAjaxManager1.ResponseScripts.Add("pushProfileToFlex('" + us.ToJson() + "'); ");
                 break;
             case "getWorkout":
                 long wid = Convert.ToInt64(hiddenAjaxValue.Value);
                 int context = Convert.ToInt32(hiddenAjaxContext.Value);
                 Workout wo = entities.UserStreamSet.OfType<Workout>().Include("WOD").Include("WOD.WODType").Include("WorkoutExtendeds").FirstOrDefault(w => w.Id == wid);
                 LoadFlexDataForWorkout(wo, Utils.ConstsUtil.toGraphContext(context));
                 RadAjaxManager1.ResponseScripts.Add("pushWorkoutToFlex('" + hiddenWorkoutData.Value + "'); ");
                 break;
         }
     }
     catch (Exception ex)
     {
         status = "ERROR: There was a problem with the action (" + ex.Message + ")" + ex.StackTrace;
         RadAjaxManager1.ResponseScripts.Add("alert('" + status.Replace("\r\n","") + "'); ");
     }
     //RadAjaxManager1.ResponseScripts.Add("UpdateStatus('" + status + "'); ");
 }