Beispiel #1
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");
        }
    }