Exemplo n.º 1
0
    public bool GetNextAndPrevPlanWeek(MemberExercisePlanWeek currentMemberPlanWeek, ref int prevMemberPlanWeekId, ref int nextMemberPlanWeekId)
    {
        prevMemberPlanWeekId = -1;
        nextMemberPlanWeekId = -1;
        string statusFinished = PrizeConstants.STATUS_PLAN_FINISHED;
        //+ PrizeConstants.STATUS_PLAN_PAID;
        MemberExercisePlanWeek aMemberPlanWeek = (from c in db.MemberExercisePlanWeeks
                                                  where c.MemberId == currentMemberPlanWeek.MemberId && c.StartDate < currentMemberPlanWeek.StartDate && c.Status.Equals(statusFinished)
                                                  orderby c.StartDate descending
                                                  select c).FirstOrDefault();

        if (aMemberPlanWeek != null)
        {
            prevMemberPlanWeekId = aMemberPlanWeek.Id;
        }

        //statusFinished = PrizeConstants.STATUS_PLAN_FINISHED + PrizeConstants.STATUS_PLAN_PAID;
        string statusCurrent = PrizeConstants.STATUS_PLAN_STARTED;

        //+ PrizeConstants.STATUS_PLAN_PAID;
        aMemberPlanWeek = (from c in db.MemberExercisePlanWeeks
                           where c.MemberId == currentMemberPlanWeek.MemberId && c.StartDate > currentMemberPlanWeek.StartDate &&
                           (c.Status.Equals(statusFinished) || c.Status.Equals(statusCurrent))
                           orderby c.StartDate ascending
                           select c).FirstOrDefault();

        if (aMemberPlanWeek != null)
        {
            nextMemberPlanWeekId = aMemberPlanWeek.Id;
        }

        return(true);
    }
Exemplo n.º 2
0
 public bool MemberInOrientation(int memberId)
 {
     try
     {
         db.Database.Connection.Open();
         string status1 = PrizeConstants.STATUS_PLAN_NOT_STARTED + PrizeConstants.STATUS_PLAN_PAID;
         string status2 = PrizeConstants.STATUS_PLAN_STARTED + PrizeConstants.STATUS_PLAN_PAID;
         MemberExercisePlanWeek memberPlanWeek = (from c in db.MemberExercisePlanWeeks
                                                  join d in db.MemberExercisePlans on c.MemberExercisePlanId equals d.Id
                                                  where c.MemberId == memberId &&
                                                  (d.Status.Equals(status1) || d.Status.Equals(status2)) &&
                                                  (c.Status.Equals(PrizeConstants.STATUS_PLAN_WEEK_STARTED) || c.Status.Equals(PrizeConstants.STATUS_PLAN_WEEK_NOT_STARTED))
                                                  orderby c.StartDate
                                                  select c).FirstOrDefault();
         if (memberPlanWeek == null)
         {
             return(false);
         }
         else
         if (memberPlanWeek.ExercisePlanWeekId != 0)
         {
             return(false);
         }
         return(true);
     }
     finally
     {
         db.Database.Connection.Close();
     }
 }
Exemplo n.º 3
0
    protected void LoadPreNextLinks()
    {
        int iWeek = this.GetLatestMeasurementWeekNum(iWeekNum - 1);
        MemberExercisePlanWeek prevWeek = null;

        if (iWeek != iWeekNum && iWeek >= 0)
        {
            prevWeek           = dbAccess.GetMemberPlanWeekByMemberPlanAndWeek(_MemberPlanWeek.MemberExercisePlanId, iWeek);
            dayPre.NavigateUrl = "/my-account/progress-status?MemberPlanWeekID=" + prevWeek.Id;
            dayPre.Text        = "Week " + (iWeek);
        }
        else
        {
            dayPre.Attributes.Add("class", "no-arrow");
        }

        iWeek = this.GetNextMeasurementWeekNum(iWeekNum);
        if (iWeek != iWeekNum)
        {
            var nextWeek = dbAccess.GetMemberPlanWeekByMemberPlanAndWeek(_MemberPlanWeek.MemberExercisePlanId, iWeek);
            if (nextWeek != null && !nextWeek.Status.Equals(PrizeConstants.STATUS_PLAN_NOT_STARTED))
            {
                dayNext.NavigateUrl = "/my-account/progress-status?MemberPlanWeekID=" + nextWeek.Id;
                dayNext.Text        = "Week " + (iWeek);
            }
            else
            {
                dayNext.Attributes.Add("class", "no-arrow");
            }
        }
        else
        {
            dayNext.Attributes.Add("class", "no-arrow");
        }
    }
Exemplo n.º 4
0
 public MemberExercisePlanWeek GetMemberPlanWeekById(int memberPlanWeekId)
 {
     try
     {
         db.Database.Connection.Open();
         MemberExercisePlanWeek memberPlanWeek = (from c in db.MemberExercisePlanWeeks
                                                  where c.Id == memberPlanWeekId
                                                  select c).FirstOrDefault();
         return(memberPlanWeek);
     }
     finally
     {
         db.Database.Connection.Close();
     }
 }
Exemplo n.º 5
0
 public MemberExercisePlanWeek GetMemberPlanWeekByMemberPlanAndWeek(int memberPlanId, int week)
 {
     try
     {
         db.Database.Connection.Open();
         MemberExercisePlanWeek memberPlanWeek = (from c in db.MemberExercisePlanWeeks
                                                  where c.MemberExercisePlanId == memberPlanId && c.Week == week
                                                  select c).FirstOrDefault();
         return(memberPlanWeek);
     }
     finally
     {
         db.Database.Connection.Close();
     }
 }
Exemplo n.º 6
0
 public MemberExercisePlanWeek GetCurrentMemberPlanWeek(int memberId)
 {
     try
     {
         db.Database.Connection.Open();
         MemberExercisePlanWeek memberPlanWeek = (from c in db.MemberExercisePlanWeeks
                                                  where c.MemberId == memberId && c.Status.Equals(PrizeConstants.STATUS_PLAN_WEEK_STARTED)
                                                  select c).FirstOrDefault();
         return(memberPlanWeek);
     }
     finally
     {
         db.Database.Connection.Close();
     }
 }
Exemplo n.º 7
0
    public string GetCurrentDailyViewURL(int memberId)
    {
        string result = "";
        MemberExercisePlanWeek memberPlanWeek = GetCurrentMemberPlanWeek(memberId);

        if (memberPlanWeek == null)
        {
            return(result);
        }
        PrizeExercisePlanWeek planWeek = GetExercisePlanWeek(memberPlanWeek.ExercisePlanWeekId);

        if (planWeek == null)
        {
            return(result);
        }
        result = String.Format("{0}?PlanWeekId={1}&MemberPlanWeekId={2}&PlanDayNumber={3}", PrizeConstants.URL_MEMBER_DAY_VIEW, planWeek.Id, memberPlanWeek.Id, PrizeCommonUtils.GetSystemDate().GetDayOfWeek());
        return(result);
    }
Exemplo n.º 8
0
    private void BindGrid()
    {
        using (DIYPTEntities db = new DIYPTEntities())
        {
            db.Database.Connection.Open();
            {
                var languages = from a in db.MemberPlanWeekResults
                                join b in db.PrizeMembers on a.MemberId equals b.UmbracoId
                                join c in db.MemberExercisePlanWeeks on a.MemberExercisePlanWeekId equals c.Id
                                join d in db.MemberExercisePlans on c.MemberExercisePlanId equals d.Id
                                join e in db.PrizeExercisePlans on d.ExercisePlanId equals e.Id
                                where a.MemberId == memberId && d.Status.EndsWith("P")
                                orderby d.StartDate descending, c.StartDate
                    select new
                {
                    Memberid     = a.MemberId,
                    Firstname    = b.Firstname,
                    Surname      = b.Surname,
                    Week         = c.Week,
                    Status       = c.Status,
                    StartDate    = c.StartDate,
                    EndDate      = c.EndDate,
                    PlanName     = e.PlanName,
                    EndWeight    = a.EndWeight,
                    EndWaist     = a.EndWaist,
                    EndBodyFat   = a.EndBodyFat,
                    EndChest     = a.EndChest,
                    EndHip       = a.EndHip,
                    EndHeartRate = a.EndHeartRate,
                    FrontPhoto   = a.FrontPhoto,
                    BackPhoto    = a.BackPhoto,
                    SidePhoto    = a.SidePhoto,
                    Tasks        = a.Tasks,
                };

                GridView1.DataSource = languages.ToList();

                GridView1.DataBind();

                MemberExercisePlan     myPlan     = null;
                MemberExercisePlanWeek myPlanWeek = null;
                if (Session["MPID"] != null)
                {
                    int mPlanId = Convert.ToInt32(Session["MPID"]);
                    myPlan = dbAccess.GetMemberExercisePlan(mPlanId);
                }
                else
                {
                    myPlan     = dbAccess.GetCurrentMemberPlanOrStartingPlan(memberId);
                    myPlanWeek = dbAccess.GetCurrentMemberPlanWeek(memberId);
                }

                this.btnSave.Enabled = false;
                if (myPlan != null)
                {
                    this.btnSave.Enabled = true;
                    var memberPlanWeeks = from a in db.MemberExercisePlanWeeks
                                          where a.MemberExercisePlanId == myPlan.Id
                                          orderby a.Week
                                          select new
                    {
                        WeekText = a.Week,
                        WeekNum  = a.Week
                    };
                    ddlWeek.DataValueField = "WeekNum";
                    ddlWeek.DataTextField  = "WeekText";
                    ddlWeek.DataSource     = memberPlanWeeks.ToList();
                    ddlWeek.DataBind();
                    int weekNum = -1;
                    if (myPlanWeek != null)
                    {
                        weekNum = myPlanWeek.Week;
                    }

                    PrizeExercisePlan plan = dbAccess.GetExercisePlan(myPlan.ExercisePlanId);

                    lblPlanInfo.Text = "Plan " + plan.PlanName + " from " + PrizeCommonUtils.ParseDateToEnglish(myPlan.StartDate) + " to " + PrizeCommonUtils.ParseDateToEnglish(myPlan.EndDate.Value);
                    LoadFoodPlanWeek(memberId, myPlan, weekNum);
                }
            }
            db.Database.Connection.Close();
        }
    }
Exemplo n.º 9
0
    protected void Page_Load(object sender, EventArgs e)
    {
        /*
         *     //Handled in BaseOrientation//
         *     if (PrizeMemberAuthUtils.CurrentUserLogin() != true)
         * return;
         */
        int memberId = PrizeMemberAuthUtils.GetMemberID();

        var exercisePlan = dbAccess.GetCurrentMemberPlanOrStartingPlan(memberId);

        if (exercisePlan == null)
        {
            PrizeMember            member  = PrizeMemberAuthUtils.GetMemberData(memberId);
            PrizeMemberPlanManager planMan = new PrizeMemberPlanManager();
            Response.Redirect(planMan.GetEmptyPlanJumpURL(member));
        }
        InitLables();
        //var member = PrizeMemberAuthUtils.GetMemberData();
        //lblTest.Text = member.Questions;


        if (Request["MemberPlanWeekID"] != null)
        {
            int memberPlanWeekId;
            int.TryParse(Request["MemberPlanWeekID"], out memberPlanWeekId);

            memberPlanWeek = dbAccess.GetMemberPlanWeekById(memberPlanWeekId);

            planWeek = dbAccess.GetExercisePlanWeek(memberPlanWeek.ExercisePlanWeekId);
        }
        else
        {
            DateTime now = PrizeCommonUtils.GetSystemDate();

            memberPlanWeek = dbAccess.GetCurrentMemberPlanWeek(memberId); //(MemberExercisePlanWeek)Session["MemberPlanWeek"];
            if (memberPlanWeek == null && PrizeCommonUtils.LessThanDaysAhead(now, exercisePlan.StartDate, 1))
            {
                memberPlanWeek = dbAccess.GetMemberPlanWeekByMemberPlanAndWeek(exercisePlan.Id, 0);
            }

            if (memberPlanWeek == null)
            {
                HideLinks();
                topInfo.Visible            = false;
                dayPre.Visible             = false;
                dayNext.Visible            = false;
                dayView.Visible            = false;
                printDay.Visible           = false;
                timesaverDiv.Visible       = false;
                timesaverDivMobile.Visible = false;
                divNotStarted.Visible      = true;
                return;
            }
            divNotStarted.Visible = false;

            planWeek = dbAccess.GetExercisePlanWeek(memberPlanWeek.ExercisePlanWeekId);
        }

        currentPlanWeekId = (int)memberPlanWeek.ExercisePlanWeekId;
        //
        dayView.HRef = dbAccess.GetCurrentDailyViewURL(memberId);
        LoadWeeklyInfo(memberId, planWeek, memberPlanWeek);

        MemberExercisePlan     myPlan   = dbAccess.GetMemberExercisePlan(memberPlanWeek.MemberExercisePlanId);
        MemberExercisePlanWeek prevWeek = dbAccess.GetMemberPlanWeekByMemberPlanAndWeek(myPlan.Id, memberPlanWeek.Week - 1);

        if (prevWeek != null)
        {
            dayPre.NavigateUrl = "/my-account/exercise-view?MemberPlanWeekID=" + prevWeek.Id;
            dayPre.Text        = "Week " + (memberPlanWeek.Week - 1);
        }
        else
        {
            dayPre.Attributes.Add("class", "no-arrow");
        }

        MemberExercisePlanWeek nextWeek = dbAccess.GetMemberPlanWeekByMemberPlanAndWeek(myPlan.Id, memberPlanWeek.Week + 1);

        if (nextWeek != null)
        {
            dayNext.NavigateUrl = "/my-account/exercise-view?MemberPlanWeekID=" + nextWeek.Id;
            dayNext.Text        = "Week " + (memberPlanWeek.Week + 1);
        }
        else
        {
            dayNext.Attributes.Add("class", "no-arrow");
        }
    }
Exemplo n.º 10
0
    protected void LoadWeeklyInfo(int memberID, PrizeExercisePlanWeek planWeek, MemberExercisePlanWeek memberPlanWeek)
    {
        dayNumber = PrizeCommonUtils.GetSystemDate().GetDayOfWeek();

        int memberId = PrizeMemberAuthUtils.GetMemberID();

        using (DIYPTEntities db = new DIYPTEntities())
        {
            db.Database.Connection.Open();

            lblDateDuration.Text = PrizeCommonUtils.ParseDateToEnglish(memberPlanWeek.StartDate) + " - "
                                   + PrizeCommonUtils.ParseDateToEnglish(memberPlanWeek.EndDate);

            for (int i = 0; i < lblDates.Count; i++)
            {
                lblDates[i].Text = PrizeCommonUtils.ParseShortDateToEnglish(memberPlanWeek.StartDate.AddDays(i));
                HyperLink linkDay = FindControl("linkDay" + (i + 1)) as HyperLink;
                if (linkDay != null && planWeek != null)
                {
                    linkDay.NavigateUrl = (String.Format("{0}?PlanWeekId={1}&MemberPlanWeekId={2}&PlanDayNumber={3}", PrizeConstants.URL_MEMBER_DAY_VIEW, planWeek.Id, memberPlanWeek.Id, i + 1));
                }
                else if (planWeek == null)
                {
                    //Orientation week
                    linkDay.NavigateUrl = "/orientation/day-" + (i + 1);
                    labels[i].Text      = "Orientation day " + (i + 1);
                }
            }
            if (planWeek == null)
            {
                lblWeekNum.Text = "Week 0";
                PrizeDataAccess dba = new PrizeDataAccess();
                if (dba.MemberInOrientation(PrizeMemberAuthUtils.GetMemberID()))
                {
                    topInfo.Visible = false;
                }
                db.Database.Connection.Close();
                return;
            }

            int iWeekNum = memberPlanWeek.Week;
            lblWeekNum.Text = "Week " + iWeekNum;

            string[] planWeekDesc      = planWeek.Description.Split('\n');
            bool     bEquipmentSession = false;
            if (strEquipments == null)
            {
                strEquipments = new List <string>();
            }
            for (int i = 0; i < planWeekDesc.Length; i++)
            {
                string[] strKeyValue = planWeekDesc[i].Split(':');
                if (strKeyValue != null && strKeyValue.Length > 1)
                {
                    if ((i == 1) && (strKeyValue[0].IndexOf("phase", StringComparison.OrdinalIgnoreCase) >= 0))
                    {
                        lblTrainingPhase.Text = strKeyValue[1];
                        continue;
                    }
                    if ((i == 2) && (strKeyValue[0].IndexOf("phase duration", StringComparison.OrdinalIgnoreCase) >= 0 || (strKeyValue[0].IndexOf("training duration", StringComparison.OrdinalIgnoreCase) >= 0)))
                    {
                        lblDuration.Text = strKeyValue[1];
                        continue;
                    }

                    if (strKeyValue[0].IndexOf("equipment", StringComparison.OrdinalIgnoreCase) >= 0)
                    {
                        bEquipmentSession = true;
                        strEquipments.Clear();
                        continue;
                    }
                }

                if (bEquipmentSession && Regex.Matches(planWeekDesc[i], @"[a-zA-Z]").Count > 0)
                {
                    strEquipments.Add(planWeekDesc[i]);
                    continue;
                }
            }

            if (strEquipments != null && strEquipments.Count > 0)
            {
                string tempLiteral = "<ul class='equipment-list'>";
                foreach (var e in strEquipments)
                {
                    if (e != " ")
                    {
                        tempLiteral += "<li>" + e + "</li>";
                    }
                }
                tempLiteral                += "</ul>";
                equipmentLiteral.Text       = tempLiteral;
                equipmentLiteralMobile.Text = tempLiteral;
                equipmentDiv.Visible        = true;
            }

            DataSet myPlan = dbAccess.GetExercisePlanInfo((int)planWeek.ExercisePlanId);
            if (myPlan.Tables[0].Rows.Count == 0)
            {
                db.Database.Connection.Close();
                return;
            }

            this.lblGoal.Text = myPlan.Tables[0].Rows[0]["ProgramName"].ToString();


            LoadDailyInfo(memberId, planWeek);

            //PrizePlanProgram myProgram = (from c in db.PrizePlanPrograms
            //                              where c.Id == planWeek.ExercisePlanId
            //                              select c).FirstOrDefault();


            db.Database.Connection.Close();
        }
    }
Exemplo n.º 11
0
    protected void Page_Load(object sender, EventArgs e)
    {
        int memberId = PrizeMemberAuthUtils.GetMemberID();

        var exercisePlan = dbAccess.GetCurrentMemberPlanOrStartingPlan(memberId);

        if (exercisePlan == null)
        {
            PrizeMember            member  = PrizeMemberAuthUtils.GetMemberData(memberId);
            PrizeMemberPlanManager planMan = new PrizeMemberPlanManager();
            Response.Redirect(planMan.GetEmptyPlanJumpURL(member));
        }

        MemberExercisePlanWeek memberPlanWeek;

        if (Request["MemberPlanWeekID"] != null)
        {
            int memberPlanWeekId;
            int.TryParse(Request["MemberPlanWeekID"], out memberPlanWeekId);
            memberPlanWeek = dbAccess.GetMemberPlanWeekById(memberPlanWeekId);
        }
        else
        {
            memberPlanWeek = dbAccess.GetCurrentMemberPlanWeek(memberId);
        }

        if (memberPlanWeek == null)
        {
            divMealPlanContent.Visible = false;
            divNotStarted.Visible      = true;
            return;
        }

        int iWeekNum = memberPlanWeek.Week;

        lblWeekNum.Text = "Week " + iWeekNum;
        divMainMealPlan.Attributes.Add("class", "tab-inner-content nodisplay wk" + iWeekNum);
        lblDateDuration.Text = PrizeCommonUtils.ParseDateToEnglish(memberPlanWeek.StartDate) + " - "
                               + PrizeCommonUtils.ParseDateToEnglish(memberPlanWeek.EndDate);

        MemberExercisePlan memberPlan = dbAccess.GetCurrentMemberPlan(memberId);

        if (memberPlan == null)
        {
            return;
        }
        PrizeExercisePlan plan = dbAccess.GetExercisePlan(memberPlan.ExercisePlanId);

        if (plan == null)
        {
            return;
        }
        lblPlanProgram.Text = plan.PrizePlanProgram.Name;

        MemberExercisePlanWeek prevWeek = dbAccess.GetMemberPlanWeekByMemberPlanAndWeek(memberPlan.Id, memberPlanWeek.Week - 1);

        if (prevWeek != null)
        {
            int prevWeekNum = iWeekNum - 1;
            weekPre.NavigateUrl = "/my-account/meal-plan?MemberPlanWeekID=" + prevWeek.Id;
            weekPre.Text        = "Week " + (memberPlanWeek.Week - 1);
        }
        else
        {
            weekPre.Attributes.Add("class", "no-arrow");
        }

        MemberExercisePlanWeek nextWeek = dbAccess.GetMemberPlanWeekByMemberPlanAndWeek(memberPlan.Id, memberPlanWeek.Week + 1);

        if (nextWeek != null)
        {
            weekNext.NavigateUrl = "/my-account/meal-plan?MemberPlanWeekID=" + nextWeek.Id;
            weekNext.Text        = "Week " + (memberPlanWeek.Week + 1);
        }
        else
        {
            weekNext.Attributes.Add("class", "no-arrow");
        }

        MemberFoodPlanWeek foodWeek = dbAccess.GetMemberFoodPlanWeek(memberId, memberPlanWeek.MemberExercisePlanId, memberPlanWeek.Week);

        if (foodWeek == null)
        {
            return;
        }
        if (foodWeek.Food1 == null || foodWeek.Food1.Equals(""))
        {
            this.colories.Visible = false;
        }
        else
        {
            lblFood1.Text = foodWeek.Food1;
        }

        if (foodWeek.Food2 == null || foodWeek.Food2.Equals(""))
        {
            this.protein.Visible = false;
        }
        else
        {
            lblFood2.Text = foodWeek.Food2;
        }

        if (foodWeek.Food3 == null || foodWeek.Food3.Equals(""))
        {
            this.carbo.Visible = false;
        }
        else
        {
            lblFood3.Text = foodWeek.Food3;
        }

        if (foodWeek.Food4 == null || foodWeek.Food4.Equals(""))
        {
            this.fats.Visible = false;
        }
        else
        {
            lblFood4.Text = foodWeek.Food4;
        }

        if (foodWeek.Food5 != null)
        {
            string[] sPersentage = foodWeek.Food5.Split(';');
            if (sPersentage.Length > 0)
            {
                lblFood5.Text = sPersentage[0];
                if (sPersentage.Length > 1)
                {
                    lblFood6.Text = sPersentage[1];
                    if (sPersentage.Length > 2)
                    {
                        lblFood7.Text = sPersentage[2];
                    }
                }
            }
        }
    }
Exemplo n.º 12
0
    protected void Page_Load(object sender, EventArgs e)
    {
        int.TryParse(Request["PlanWeekId"], out iPlanWeekId);
        int.TryParse(Request["PlanDayNumber"], out iDay);
        int.TryParse(Request["MemberPlanWeekId"], out memberPlanWeekId);

        MemberExercisePlanWeek memberPlanWeek = dbAccess.GetMemberPlanWeekById(memberPlanWeekId);

        if (memberPlanWeek != null)
        {
            lblDate.Text = PrizeCommonUtils.ParseDateToEnglish(memberPlanWeek.StartDate.AddDays(iDay - 1));
        }
        lblDayNum.Text      = "" + iDay;
        lblDayTypeName.Text = PrizeConstants.STR_NO_TRAINNING;
        DataSet ds = dbAccess.GetMemberWeeklyInfo(iPlanWeekId);

        foreach (DataRow row in ds.Tables[0].Rows)
        {
            int iWeekDay = (int)row[0];
            if (iWeekDay == iDay)
            {
                lblDayTypeName.Text = (String)row[2];
            }
        }
        if (lblDayTypeName.Text.ToLower() == PrizeConstants.STR_NO_TRAINNING.ToLower())
        {
            divWarmup.Visible = divCooldown.Visible = divLegend.Visible = false;
            divRest.Visible   = true;
        }

        lblDay.Text = PrizeCommonUtils.ParseWeekDayToEnglish(iDay);
        MemberExercisePlan myPlan = dbAccess.GetMemberExercisePlan(memberPlanWeek.MemberExercisePlanId);

        if (iDay > 1)
        {
            preDay.NavigateUrl = (String.Format("{0}?PlanWeekId={1}&MemberPlanWeekId={2}&PlanDayNumber={3}", PrizeConstants.URL_MEMBER_DAY_VIEW, iPlanWeekId, memberPlanWeekId, iDay - 1));
            preDay.Text        = "Previous Day";
        }
        else
        {
            MemberExercisePlanWeek prevWeek = dbAccess.GetMemberPlanWeekByMemberPlanAndWeek(myPlan.Id, memberPlanWeek.Week - 1);
            if (prevWeek != null)
            {
                preDay.NavigateUrl = (String.Format("{0}?PlanWeekId={1}&MemberPlanWeekId={2}&PlanDayNumber={3}", PrizeConstants.URL_MEMBER_DAY_VIEW, iPlanWeekId, prevWeek.Id, 7));
                preDay.Text        = "Previous Day";
            }
            else
            {
                preDay.Attributes.Add("class", "no-arrow");
            }
        }

        if (iDay < 7)
        {
            nextDay.NavigateUrl = (String.Format("{0}?PlanWeekId={1}&MemberPlanWeekId={2}&PlanDayNumber={3}", PrizeConstants.URL_MEMBER_DAY_VIEW, iPlanWeekId, memberPlanWeekId, iDay + 1));
            nextDay.Text        = "Next Day";
        }
        else
        {
            MemberExercisePlanWeek nextWeek = dbAccess.GetMemberPlanWeekByMemberPlanAndWeek(myPlan.Id, memberPlanWeek.Week + 1);
            if (nextWeek != null)
            {
                nextDay.NavigateUrl = (String.Format("{0}?PlanWeekId={1}&MemberPlanWeekId={2}&PlanDayNumber={3}", PrizeConstants.URL_MEMBER_DAY_VIEW, iPlanWeekId, nextWeek.Id, 1));
                nextDay.Text        = "Next Day";
            }
            else
            {
                nextDay.Attributes.Add("class", "no-arrow");
            }
        }

        InitPageControls();

        DivAdvanceEquipment.Visible = false;
        PrizeDataAccess db = new PrizeDataAccess();
        var             memberExercisePlan = db.GetCurrentMemberPlanOrStartingPlan(PrizeMemberAuthUtils.GetMemberID());

        if (memberExercisePlan != null)
        {
            var exercisePlan = db.GetExercisePlan(memberExercisePlan.ExercisePlanId);
            if (exercisePlan != null)
            {
                if (exercisePlan.PlanName.ToLower().Contains("home") &&
                    (exercisePlan.PlanName.ToLower().Contains("intermediate")
                     ||
                     exercisePlan.PlanName.ToLower().Contains("advanced"))
                    )
                {
                    DivAdvanceEquipment.Visible = true;
                }
            }
        }
        switch (lblDayTypeName.Text.Trim())
        {
        case "Time to celebrate":
            divWarmup.Visible           = divCooldown.Visible = divLegend.Visible = false;
            divRest.Visible             = true;
            DivAdvanceEquipment.Visible = false;
            break;

        case "30min brisk walk":
        case "Brisk walk":
            divWarmup.Visible           = divCooldown.Visible = divLegend.Visible = false;
            divWalk.Visible             = true;
            DivAdvanceEquipment.Visible = false;
            break;

        case "30-60min weekend physical activity":
        case "Weekend physical activity":
            divWarmup.Visible           = divCooldown.Visible = divLegend.Visible = false;
            divWeekend.Visible          = true;
            DivAdvanceEquipment.Visible = false;
            break;

        case "Own 1hr cardio":
        case "Own training":
        case "Own cardio":
            divWarmup.Visible           = divCooldown.Visible = divLegend.Visible = false;
            divCardio.Visible           = true;
            DivAdvanceEquipment.Visible = false;
            break;

        case "Milestone workout = 20x pushups, squats, situps":
        case "Milestone workout 2":
            divWarmup.Visible           = divCooldown.Visible = divLegend.Visible = false;
            divSquat.Visible            = true;
            DivAdvanceEquipment.Visible = false;
            break;

        case "Milestone workout = 20 pushups & make your bed":
        case "Milestone workout 1":
            divWarmup.Visible           = divCooldown.Visible = divLegend.Visible = false;
            divPushup.Visible           = true;
            DivAdvanceEquipment.Visible = false;
            break;

        case "Measurement day and rest":
            divWarmup.Visible           = divCooldown.Visible = divLegend.Visible = false;
            divMeasurement.Visible      = true;
            DivAdvanceEquipment.Visible = false;
            break;

        case "Milestone workout = 20 star jumps & make your bed":
            divWarmup.Visible           = divCooldown.Visible = divLegend.Visible = false;
            DivAdvanceEquipment.Visible = false;
            //divMeasurement.Visible = true;
            break;

        default:
            break;
        }
        LoadDailyInfo(iPlanWeekId, iDay);

        // nextDay.Text = "Next day tuesday";
        // nextDay.NavigateUrl = "/tuesday#?";
    }
Exemplo n.º 13
0
    public int BuyNewPlan(int newPlanId, ref PrizeExercisePlan prizePlan, ref MemberExercisePlan newMemberPlan)
    {
        DIYPTEntities db = new DIYPTEntities();

        try
        {
            if (PrizeMemberAuthUtils.CurrentUserLogin() != true)
            {
                return(PrizeErrorCode.ERROR_NOT_LOGGED_IN);
            }
            int memberId = PrizeMemberAuthUtils.GetMemberID();

            db.Database.Connection.Open();

            PrizeExercisePlan plan = (from c in db.PrizeExercisePlans
                                      where c.Id == newPlanId
                                      select c).FirstOrDefault();

            if (plan == null)
            {
                return(-1);
            }

            //using (TransactionScope transaction = new TransactionScope())
            //{
            if (plan == null)
            {
                return(PrizeErrorCode.ERROR_PLAN_NOT_EXIST);
            }

            MemberExercisePlan myExistingPaidPlan = (from c in db.MemberExercisePlans
                                                     where c.MemberId == memberId &&
                                                     (c.Status.Equals(PrizeConstants.STATUS_PLAN_STARTED + PrizeConstants.STATUS_PLAN_PAID) ||
                                                      c.Status.Equals(PrizeConstants.STATUS_PLAN_NOT_STARTED + PrizeConstants.STATUS_PLAN_PAID))
                                                     orderby c.EndDate descending
                                                     select c).FirstOrDefault();
            DateTime currentEndDate;
            if (myExistingPaidPlan != null)
            {
                currentEndDate = myExistingPaidPlan.EndDate.Value;
            }
            else
            {
                currentEndDate = PrizeCommonUtils.GetSystemDate();
            }

            List <MemberExercisePlan> myNotPaidPlans = (from c in db.MemberExercisePlans
                                                        where c.MemberId == memberId && (c.Status.EndsWith(PrizeConstants.STATUS_PLAN_NOT_PAID) || c.Status.EndsWith(PrizeConstants.STATUS_PLAN_MANUAL_PAYMENT))
                                                        select c).ToList();

            foreach (MemberExercisePlan notPaidPlan in myNotPaidPlans)
            {
                IQueryable <MemberExercisePlanWeek> notPaidPlanWeeks = (from c in db.MemberExercisePlanWeeks
                                                                        where c.MemberExercisePlanId == notPaidPlan.Id
                                                                        select c);
                foreach (var week in notPaidPlanWeeks)
                {
                    MemberPlanWeekResult weekResult = (from c in db.MemberPlanWeekResults
                                                       where c.MemberExercisePlanWeekId == week.Id
                                                       select c).SingleOrDefault();
                    db.MemberExercisePlanWeeks.Remove(week);
                    db.MemberPlanWeekResults.Remove(weekResult);
                }
                notPaidPlan.Status = PrizeConstants.STATUS_PLAN_NOT_STARTED + PrizeConstants.STATUS_PLAN_PAYMENT_CANCELLED;

                List <MemberManualPayment> manualPayments = (from c in db.MemberManualPayments
                                                             where c.MemberExercisePlanId == notPaidPlan.Id && c.Status.StartsWith(PrizeConstants.STATUS_PLAN_MANUAL_PAYMENT_NOT_APPROVED)
                                                             select c).ToList();
                foreach (var notPaidRecord in manualPayments)
                {
                    db.MemberManualPayments.Remove(notPaidRecord);
                    db.SaveChanges();
                }
            }
            db.SaveChanges();

            DateTime startDate = PrizeCommonUtils.GetNextWeekStart(currentEndDate);
            DateTime endDate   = PrizeCommonUtils.GetWeekEnd(startDate);

            MemberExercisePlan myPlan = new MemberExercisePlan();
            myPlan.MemberId       = memberId;
            myPlan.ExercisePlanId = plan.Id;
            myPlan.StartDate      = startDate;
            myPlan.Status         = PrizeConstants.STATUS_PLAN_NOT_STARTED + PrizeConstants.STATUS_PLAN_NOT_PAID;              //Not paid
            db.MemberExercisePlans.Add(myPlan);
            db.SaveChanges();
            MemberPlanWeekResult myWeekResult;

            if (plan.IsTrialPlan != 1)
            {
                MemberExercisePlanWeek myPlanWeekOrientation = new MemberExercisePlanWeek();
                myPlanWeekOrientation.MemberExercisePlanId = myPlan.Id;
                myPlanWeekOrientation.ExercisePlanWeekId   = 0;
                myPlanWeekOrientation.MemberId             = memberId;
                myPlanWeekOrientation.StartDate            = startDate;
                myPlanWeekOrientation.EndDate = endDate;
                myPlanWeekOrientation.Status  = PrizeConstants.STATUS_PLAN_WEEK_NOT_STARTED;
                myPlanWeekOrientation.Week    = 0;
                db.MemberExercisePlanWeeks.Add(myPlanWeekOrientation);
                db.SaveChanges();

                myWeekResult          = new MemberPlanWeekResult();
                myWeekResult.MemberId = memberId;
                myWeekResult.MemberExercisePlanWeekId = myPlanWeekOrientation.Id;
                InitialiseWeekResult(ref myWeekResult);
                db.MemberPlanWeekResults.Add(myWeekResult);
                db.SaveChanges();
                myPlan.EndDate = endDate;
                startDate      = startDate.AddDays(7);
                endDate        = endDate.AddDays(7);
            }

            IList <PrizeExercisePlanWeek> planWeeks = plan.PrizeExercisePlanWeeks.OrderBy(s => s.StartWeek).ToList();
            foreach (PrizeExercisePlanWeek planWeek in planWeeks)
            {
                for (int i = planWeek.StartWeek; i <= planWeek.EndWeek; i++)
                {
                    MemberExercisePlanWeek myPlanWeek = new MemberExercisePlanWeek();
                    myPlanWeek.MemberExercisePlanId = myPlan.Id;
                    myPlanWeek.ExercisePlanWeekId   = planWeek.Id;
                    myPlanWeek.MemberId             = memberId;
                    myPlanWeek.StartDate            = startDate;
                    myPlanWeek.EndDate = endDate;
                    myPlanWeek.Status  = PrizeConstants.STATUS_PLAN_WEEK_NOT_STARTED;
                    myPlanWeek.Week    = i;
                    db.MemberExercisePlanWeeks.Add(myPlanWeek);
                    db.SaveChanges();

                    myWeekResult          = new MemberPlanWeekResult();
                    myWeekResult.MemberId = memberId;
                    myWeekResult.MemberExercisePlanWeekId = myPlanWeek.Id;
                    InitialiseWeekResult(ref myWeekResult);
                    db.MemberPlanWeekResults.Add(myWeekResult);
                    myPlan.EndDate = endDate;
                    db.SaveChanges();

                    startDate = startDate.AddDays(7);
                    endDate   = endDate.AddDays(7);
                }
            }

            //transaction.Complete();
            newMemberPlan = myPlan;
            prizePlan     = plan;

            return(newPlanId);
            //}
        }
        finally
        {
            db.Dispose();
        }
    }
Exemplo n.º 14
0
    public static bool UpdateMemberPlans()
    {
        using (DIYPTEntities db = new DIYPTEntities())
        {
            try
            {
                db.Database.Connection.Open();

                DateTime today = PrizeCommonUtils.GetDayStart(PrizeCommonUtils.GetSystemDate());
                MemberExercisePlanWeek startingPlanWeek;
                String availableStatus = PrizeConstants.STATUS_PLAN_STARTED + PrizeConstants.STATUS_PLAN_PAID;
                IQueryable <MemberExercisePlan> plans = (from c in db.MemberExercisePlans
                                                         where c.Status.Equals(availableStatus)
                                                         orderby c.MemberId, c.Id
                                                         select c);

                foreach (MemberExercisePlan plan in plans)
                {
                    MemberExercisePlanWeek finishingPlanWeek = (from c in db.MemberExercisePlanWeeks
                                                                where c.MemberExercisePlanId == plan.Id && c.EndDate <= today &&
                                                                c.Status.Equals(PrizeConstants.STATUS_PLAN_WEEK_STARTED)
                                                                orderby c.ExercisePlanWeekId
                                                                select c).FirstOrDefault();

                    if (finishingPlanWeek != null)
                    {
                        finishingPlanWeek.Status = PrizeConstants.STATUS_PLAN_WEEK_FINISHED;
                        startingPlanWeek         = (from c in db.MemberExercisePlanWeeks
                                                    where c.StartDate >= finishingPlanWeek.EndDate && c.Status.Equals(PrizeConstants.STATUS_PLAN_WEEK_NOT_STARTED) &&
                                                    c.MemberExercisePlanId == plan.Id
                                                    orderby c.StartDate
                                                    select c).FirstOrDefault();
                        if (startingPlanWeek != null)
                        {
                            MemberPlanWeekResult finishingResult = (from c in db.MemberPlanWeekResults
                                                                    where c.MemberExercisePlanWeekId == finishingPlanWeek.Id
                                                                    select c).FirstOrDefault();

                            MemberPlanWeekResult startingResult = (from c in db.MemberPlanWeekResults
                                                                   where c.MemberExercisePlanWeekId == startingPlanWeek.Id
                                                                   select c).FirstOrDefault();
                            CopyWeekResult(ref startingResult, ref finishingResult);
                            startingPlanWeek.Status = PrizeConstants.STATUS_PLAN_WEEK_STARTED;
                        }
                        else
                        {
                            plan.Status = PrizeConstants.STATUS_PLAN_FINISHED + PrizeConstants.STATUS_PLAN_PAID;
                        }
                    }
                }

                availableStatus = PrizeConstants.STATUS_PLAN_NOT_STARTED + PrizeConstants.STATUS_PLAN_PAID;
                plans           = (from c in db.MemberExercisePlans
                                   where c.Status.Equals(availableStatus)
                                   orderby c.MemberId
                                   select c);

                foreach (MemberExercisePlan plan in plans)
                {
                    startingPlanWeek = (from c in db.MemberExercisePlanWeeks
                                        where c.StartDate <= today && c.Status.Equals(PrizeConstants.STATUS_PLAN_WEEK_NOT_STARTED) &&
                                        c.MemberExercisePlanId == plan.Id
                                        orderby c.StartDate
                                        select c).FirstOrDefault();
                    if (startingPlanWeek != null)
                    {
                        MemberPlanWeekResult startingResult = (from c in db.MemberPlanWeekResults
                                                               where c.MemberExercisePlanWeekId == startingPlanWeek.Id
                                                               select c).FirstOrDefault();
                        MemberExercisePlanWeek finishedWeek = (from c in db.MemberExercisePlanWeeks
                                                               where c.EndDate < startingPlanWeek.StartDate && c.Status.Equals(PrizeConstants.STATUS_PLAN_WEEK_FINISHED)
                                                               select c).FirstOrDefault();
                        if (finishedWeek != null)
                        {
                            MemberPlanWeekResult finishingResult = (from c in db.MemberPlanWeekResults
                                                                    where c.MemberExercisePlanWeekId == finishedWeek.Id
                                                                    select c).FirstOrDefault();
                            CopyWeekResult(ref startingResult, ref finishingResult);
                        }

                        startingPlanWeek.Status = PrizeConstants.STATUS_PLAN_WEEK_STARTED;
                        plan.Status             = PrizeConstants.STATUS_PLAN_STARTED + PrizeConstants.STATUS_PLAN_PAID;
                    }
                }
                db.SaveChanges();
                return(true);
            }
            catch (Exception e)
            {
                PrizeLogs.SaveSystemErrorLog(0, 0, PrizeConstants.SystemErrorLevel.LevelSerious, typeof(PrizeMemberPlanManager).ToString(),
                                             "UpdateMemberPlans", e.Message, e.InnerException == null ? "" : e.InnerException.Message);
                return(false);
            }
            finally
            {
                db.Database.Connection.Close();
            }
        }
    }
Exemplo n.º 15
0
    protected string UpdateMemberPlanWeekPhoto(MemberExercisePlanWeek memberPlanWeek, FileUpload loader, int iType = 0)
    {
        FileUpload tempFileupload       = loader;
        string     sPhotoTypeName       = "";
        string     attachmentServerPath = "";

        if (iType == 0)
        {
            sPhotoTypeName = "front";
        }
        if (iType == 1)
        {
            sPhotoTypeName = "side";
        }
        if (iType == 2)
        {
            sPhotoTypeName = "back";
        }

        string sSuffix         = Path.GetExtension(tempFileupload.FileName);
        string sServerFileName = memberPlanWeek.MemberId + "_" + PrizeCommonUtils.ParseDateTimeSimple(memberPlanWeek.StartDate) + "_" + sPhotoTypeName + sSuffix;

        if (tempFileupload != null && !string.IsNullOrEmpty(tempFileupload.FileName))
        {
            string uploadPath = @"d:\sites\jrguico\diypt.com.au\home\member_images";
            //string uploadPath = @"C:\workspace\asp_project\diypt.club\home\member_images";
            attachmentServerPath = String.Format(@"http://{0}/member_images/{1}", HttpContext.Current.Request.Url.Authority, sServerFileName);
            decimal attachmentFileSize = Math.Round(Convert.ToDecimal(tempFileupload.PostedFile.ContentLength / 1024), 2);

            //if (attachmentFileSize + Helper.GetTrialTotalAttachmentSize(TrialId) < Convert.ToDecimal(ConfigurationManager.AppSettings["TotalAttachmentSizeLimit"]))
            if (attachmentFileSize < 15000)
            {
                string[] dirs         = Directory.GetFiles(uploadPath);
                string   folderPath   = String.Format(@"\{0}", sServerFileName);
                string   fullFilePath = uploadPath + folderPath;

                tempFileupload.SaveAs(fullFilePath);
                ImageHelper.RotateImageByExifOrientationData(fullFilePath, fullFilePath, System.Drawing.Imaging.ImageFormat.Jpeg, true);
                using (DIYPTEntities db = new DIYPTEntities())
                {
                    MemberPlanWeekResult weekResult = (from c in db.MemberPlanWeekResults
                                                       where c.MemberExercisePlanWeekId == memberPlanWeek.Id
                                                       select c).FirstOrDefault();
                    if (weekResult != null)
                    {
                        switch (iType)
                        {
                        case 0:
                            weekResult.FrontPhoto = attachmentServerPath;
                            break;

                        case 1:
                            weekResult.SidePhoto = attachmentServerPath;
                            break;

                        case 2:
                            weekResult.BackPhoto = attachmentServerPath;
                            break;

                        default:
                            break;
                        }
                        db.SaveChanges();
                    }
                }
            }
            else
            {
                Response.Write("<script>alert('You cannot attach this file. The maximum file size limit is 15mb.');</script>");
                return("");
            }
        }
        else
        {
            Response.Write("<script>alert('Please choose a file to attach.');</script>");
        }

        WeekResults = dbAccess.GetMemberPlanResults(_MemberPlanWeek.MemberExercisePlanId);

        return(attachmentServerPath);
    }
Exemplo n.º 16
0
    protected void Page_Load(object sender, EventArgs e)
    {
        int memberId = PrizeMemberAuthUtils.GetMemberID();

        var exercisePlan = dbAccess.GetCurrentMemberPlanOrStartingPlan(memberId);

        if (exercisePlan == null)
        {
            PrizeMember            member  = PrizeMemberAuthUtils.GetMemberData(memberId);
            PrizeMemberPlanManager planMan = new PrizeMemberPlanManager();
            Response.Redirect(planMan.GetEmptyPlanJumpURL(member));
        }

        if (int.TryParse(Request["MemberPlanWeekId"], out memberPlanWeekId))
        {
            _MemberPlanWeek = dbAccess.GetMemberPlanWeekById(memberPlanWeekId);
        }

        if (_MemberPlanWeek == null)
        {
            _MemberPlanWeek = dbAccess.GetCurrentMemberPlanWeek(memberId);
        }

        if (_MemberPlanWeek == null)
        {
            divMeasurement.Visible        = false;
            btnUpdateProgress.Enabled     = false;
            this.photoPanelUpload.Visible = false;
            return;
        }

        InitPageControls();

        frontUpload.Attributes["onchange"] = "UploadFile(this)";
        sideUpload.Attributes["onchange"]  = "UploadFile(this)";
        backUpload.Attributes["onchange"]  = "UploadFile(this)";

        _PlanWeek = dbAccess.GetExercisePlanWeek(_MemberPlanWeek.ExercisePlanWeekId);

        iWeekNum = this.GetLatestMeasurementWeekNum(_MemberPlanWeek.Week);

        if (iWeekNum != _MemberPlanWeek.Week)
        {
            _MemberPlanWeek = dbAccess.GetMemberPlanWeekByMemberPlanAndWeek(_MemberPlanWeek.MemberExercisePlanId, iWeekNum);
        }
        if (_MemberPlanWeek == null)
        {
            divMeasurement.Visible        = false;
            btnUpdateProgress.Enabled     = false;
            this.photoPanelUpload.Visible = false;
            return;
        }

        if (!PrizeConstants.WEEKS_NEEDS_RESULT.Contains(iWeekNum))
        {
            divMeasurement.Visible = false;
        }

        lblWeekNum.Text = iWeekNum.ToString();
        //lblWeekNum2.Text = lblWeekNum.Text;
        lblWeekNum3.Text = iWeekNum.ToString();

        if (!IsPostBack)
        {
            WeekResults = dbAccess.GetMemberPlanResults(_MemberPlanWeek.MemberExercisePlanId);

            LoadWeeklyResult(WeekResults);

            LoadMemberPhotos(iWeekNum, WeekResults);

            DrawProgressGraph((int)_MemberPlanWeek.MemberExercisePlanId, WeekResults);

            LoadPreNextLinks();
        }


        MemberExercisePlan myPlan = dbAccess.GetCurrentMemberPlan(PrizeMemberAuthUtils.GetMemberID());

        if (myPlan != null)
        {
            PrizeExercisePlan plan = dbAccess.GetExercisePlan(myPlan.ExercisePlanId);
            if (plan != null)
            {
                if (plan.PlanName.ToLower().Contains("muscle"))
                {
                    lblMeasurement3.Text            = "Right arm biceps (cm)";
                    lblMeasurementGraph3.Text       = "Right arm biceps";
                    lblMeasurementMetricGraph3.Text = "(cm)";
                    lblMeasurement4.Text            = "Chest (cm)";
                    lblMeasurementGraph4.Text       = "Chest";
                    lblMeasurementMetricGraph4.Text = "(cm)";
                    lblMeasurement5.Text            = "Right thigh (cm)";
                    lblMeasurementGraph5.Text       = "Right thigh";
                    lblMeasurementMetricGraph5.Text = "(cm)";
                }
                if (plan.PlanName.ToLower().Contains("tone"))
                {
                    lblMeasurement3.Text            = "Right arm biceps (cm)";
                    lblMeasurementGraph3.Text       = "Right arm biceps";
                    lblMeasurementMetricGraph3.Text = "(cm)";
                    lblMeasurement4.Text            = "Hips (cm)";
                    lblMeasurementGraph4.Text       = "Hips";
                    lblMeasurementMetricGraph4.Text = "(cm)";
                    lblMeasurement5.Text            = "Right thigh (cm)";
                    lblMeasurementGraph5.Text       = "Right thigh";
                    lblMeasurementMetricGraph5.Text = "(cm)";
                }
                if (plan.PlanName.ToLower().Contains("weight"))
                {
                    lblMeasurement3.Text            = "Chest (cm)";
                    lblMeasurementGraph3.Text       = "Chest";
                    lblMeasurementMetricGraph3.Text = "(cm)";
                    lblMeasurement4.Text            = "Hips (cm)";
                    lblMeasurementGraph4.Text       = "Hips";
                    lblMeasurementMetricGraph4.Text = "(cm)";
                    lblMeasurement5.Text            = "Heart rate (per min)";
                    lblMeasurementGraph5.Text       = "Heart rate";
                    lblMeasurementMetricGraph5.Text = "(per min)";
                }
            }
        }
    }