Exemplo n.º 1
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();
        }
    }