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

            try
            {
                JavaScriptSerializer serializer = new JavaScriptSerializer();
                Affine.Data.json.WOD wodJson    = serializer.Deserialize <Affine.Data.json.WOD>(atiWodJson.Value);
                aqufitEntities       entities   = new aqufitEntities();

                // TODO: check if there is already a WOD of the same name
                long wodTypeId = Convert.ToInt64(ddlWODType.SelectedValue);
                int  standard  = UserInfo.IsSuperUser ? 1 : 0;
                long userKey   = GroupSettings != null ? this.GroupSettings.Id : this.UserSettings.Id;
                WOD  wod       = new WOD()
                {
                    Difficulty      = wodJson.Difficulty,
                    Standard        = (short)standard,
                    Name            = Affine.Utils.Web.WebUtils.MakeWebSafeString(txtWorkoutName.Text),
                    WODType         = entities.WODTypes.First(t => t.Id == wodTypeId),
                    UserSettingsKey = userKey,
                    Description     = Affine.Utils.Web.WebUtils.MakeWebSafeString(txtDescription.Text),
                    UserName        = GroupSettings != null ? this.GroupSettings.UserName : this.UserSettings.UserName,
                    CreationDate    = DateTime.Now.ToUniversalTime()
                };
                if (wodTypeId == (int)Affine.Utils.WorkoutUtil.WodType.AMRAP)
                {
                    wod.TimeSpan = atiTimeSpan.Time;
                }
                entities.AddToWODs(wod);
                foreach (Affine.Data.json.WODSet setJson in wodJson.WODSets)
                {
                    WODSet wodSet = new WODSet()
                    {
                        WOD = wod
                    };
                    //Affine.Data.Exercise[] exerciseArray = entities.Exercises.Where(Affine.Utils.Linq.LinqUtils.BuildContainsExpression<Affine.Data.Exercise, long>(ex => ex.Id, setJson.WODExercises.Select(ee => ee.ExcercisKey ).ToArray() )).ToArray();
                    foreach (Affine.Data.json.WODExercise exJson in setJson.WODExercises)
                    {
                        double      mdist   = exJson.MenDist > 0 ? Utils.UnitsUtil.unitsToSystemDefualt(exJson.MenDist, Utils.UnitsUtil.ToUnit(exJson.MenDistUnits)) : -1;
                        double      wdist   = exJson.WomenDist > 0 ? Utils.UnitsUtil.unitsToSystemDefualt(exJson.WomenDist, Utils.UnitsUtil.ToUnit(exJson.WomenDistUnits)) : -1;
                        double      mweight = exJson.MenRx > 0 ? Utils.UnitsUtil.unitsToSystemDefualt(exJson.MenRx, Utils.UnitsUtil.ToUnit(exJson.MenRxUnits)) : -1;
                        double      wweight = exJson.WomenRx > 0 ? Utils.UnitsUtil.unitsToSystemDefualt(exJson.WomenRx, Utils.UnitsUtil.ToUnit(exJson.WomenRxUnits)) : -1;
                        WODExercise wodEx   = new WODExercise()
                        {
                            MenDist   = mdist,
                            WomenDist = wdist,
                            WODSet    = wodSet,
                            MenRx     = mweight,
                            WomenRx   = wweight,
                            Reps      = exJson.Reps,
                            Order     = exJson.Order,
                            Notes     = Affine.Utils.Web.WebUtils.MakeWebSafeString(exJson.Notes),
                            Exercise  = entities.Exercises.First(ee => ee.Id == exJson.ExcercisKey)
                        };
                    }
                }
                entities.SaveChanges();
                // Now we add to peoples favs
                // ** This no longer happens here.. it happens when the workout is "scheduled" for the group that it gets added to the list..
                WOD newWOD = entities.WODs.Where(w => w.UserSettingsKey == userKey).OrderByDescending(w => w.Id).First();
                if (GroupSettings == null)
                {   // simply add for this user..
                    User2WODFav fav = new User2WODFav()
                    {
                        UserSetting = entities.UserSettings.First(us => us.Id == UserSettings.Id),
                        WOD         = newWOD
                    };
                    entities.AddToUser2WODFav(fav);
                    entities.SaveChanges();
                }
                else
                {
                    User2WODFav fav = new User2WODFav()
                    {
                        UserSetting = entities.UserSettings.First(us => us.Id == GroupSettings.Id),
                        WOD         = newWOD
                    };
                    entities.AddToUser2WODFav(fav);
                    entities.SaveChanges();
                }
                if (GroupSettings != null)
                {   // if this was a group wod.. we want to bounce back to the scheduling page now...
                    Response.Redirect(ResolveUrl("~") + "group/" + GroupSettings.UserName + "?w=" + newWOD.Id, true);
                    return;
                }
                string baseUrl = ResolveUrl("~");
                RadAjaxManager1.ResponseScripts.Add("Aqufit.Windows.WorkoutSavedDialog.open(" + newWOD.Id + ");");
                //status = "Your Workout has been saved.  It will now show up in your Workout List";
            }
            catch (Exception ex)
            {
                status = "There was a problem saving your workout: " + ex.Message + " " + ex.InnerException;
            }
            RadAjaxManager1.ResponseScripts.Add(" UpdateStatus('" + status + "');");
        }
        protected void bSaveWOD_Click(object sender, EventArgs e)
        {
            string status = string.Empty;
            try
            {
                JavaScriptSerializer serializer = new JavaScriptSerializer();
                Affine.Data.json.WOD wodJson = serializer.Deserialize<Affine.Data.json.WOD>(atiWodJson.Value);
                aqufitEntities entities = new aqufitEntities();

                // TODO: check if there is already a WOD of the same name
                long wodTypeId = Convert.ToInt64(ddlWODType.SelectedValue);
                int standard = UserInfo.IsSuperUser ? 1 : 0;
                long userKey = GroupSettings != null ? this.GroupSettings.Id : this.UserSettings.Id;
                WOD wod = new WOD()
                {
                    Difficulty = wodJson.Difficulty,
                    Standard = (short)standard,
                    Name = Affine.Utils.Web.WebUtils.MakeWebSafeString( txtWorkoutName.Text ),
                    WODType = entities.WODTypes.First(t => t.Id == wodTypeId),
                    UserSettingsKey = userKey,
                    Description = Affine.Utils.Web.WebUtils.MakeWebSafeString(txtDescription.Text),
                    UserName = GroupSettings != null ? this.GroupSettings.UserName : this.UserSettings.UserName,
                    CreationDate = DateTime.Now.ToUniversalTime()
                };
                if (wodTypeId == (int)Affine.Utils.WorkoutUtil.WodType.AMRAP)
                {
                    wod.TimeSpan = atiTimeSpan.Time;
                }
                entities.AddToWODs(wod);
                foreach (Affine.Data.json.WODSet setJson in wodJson.WODSets)
                {
                    WODSet wodSet = new WODSet()
                    {
                        WOD = wod
                    };
                    //Affine.Data.Exercise[] exerciseArray = entities.Exercises.Where(Affine.Utils.Linq.LinqUtils.BuildContainsExpression<Affine.Data.Exercise, long>(ex => ex.Id, setJson.WODExercises.Select(ee => ee.ExcercisKey ).ToArray() )).ToArray();
                    foreach (Affine.Data.json.WODExercise exJson in setJson.WODExercises)
                    {
                        double mdist = exJson.MenDist > 0 ? Utils.UnitsUtil.unitsToSystemDefualt(exJson.MenDist, Utils.UnitsUtil.ToUnit(exJson.MenDistUnits)) : -1;
                        double wdist = exJson.WomenDist > 0 ? Utils.UnitsUtil.unitsToSystemDefualt(exJson.WomenDist, Utils.UnitsUtil.ToUnit(exJson.WomenDistUnits)) : -1;
                        double mweight = exJson.MenRx > 0 ? Utils.UnitsUtil.unitsToSystemDefualt(exJson.MenRx, Utils.UnitsUtil.ToUnit(exJson.MenRxUnits)) : -1;
                        double wweight = exJson.WomenRx > 0 ? Utils.UnitsUtil.unitsToSystemDefualt(exJson.WomenRx, Utils.UnitsUtil.ToUnit(exJson.WomenRxUnits)) : -1;
                        WODExercise wodEx = new WODExercise()
                        {
                            MenDist = mdist,
                            WomenDist = wdist,
                            WODSet = wodSet,
                            MenRx = mweight,
                            WomenRx = wweight,
                            Reps = exJson.Reps,
                            Order = exJson.Order,
                            Notes = Affine.Utils.Web.WebUtils.MakeWebSafeString(exJson.Notes),
                            Exercise = entities.Exercises.First(ee => ee.Id == exJson.ExcercisKey)
                        };
                    }
                }
                entities.SaveChanges();
                // Now we add to peoples favs
                // ** This no longer happens here.. it happens when the workout is "scheduled" for the group that it gets added to the list..
                WOD newWOD = entities.WODs.Where(w => w.UserSettingsKey == userKey).OrderByDescending(w => w.Id).First();
                if (GroupSettings == null)
                {   // simply add for this user..
                    User2WODFav fav = new User2WODFav()
                    {
                        UserSetting = entities.UserSettings.First(us => us.Id == UserSettings.Id),
                        WOD = newWOD
                    };
                    entities.AddToUser2WODFav(fav);
                    entities.SaveChanges();
                }
                else
                {
                    User2WODFav fav = new User2WODFav()
                    {
                        UserSetting = entities.UserSettings.First(us => us.Id == GroupSettings.Id),
                        WOD = newWOD
                    };
                    entities.AddToUser2WODFav(fav);
                    entities.SaveChanges();
                }
                if (GroupSettings != null)
                {   // if this was a group wod.. we want to bounce back to the scheduling page now...
                    Response.Redirect(ResolveUrl("~") + "group/" + GroupSettings.UserName + "?w=" + newWOD.Id, true);
                    return;
                }
                string baseUrl = ResolveUrl("~");
                RadAjaxManager1.ResponseScripts.Add("Aqufit.Windows.WorkoutSavedDialog.open(" + newWOD.Id + ");");
                //status = "Your Workout has been saved.  It will now show up in your Workout List";
            }
            catch (Exception ex)
            {
                status = "There was a problem saving your workout: " + ex.Message + " " + ex.InnerException;
            }
            RadAjaxManager1.ResponseScripts.Add(" UpdateStatus('"+status+"');");
        }