Ejemplo n.º 1
0
        public ActionResult ViewChallenge()
        {
            StringBuilder traceLog = new StringBuilder();

            if (Login.IsSessionExpire(Convert.ToString(HttpContext.Session[Message.LoginUserName])) ||
                Convert.ToString(HttpContext.Session[ConstantHelper.constUserType]) != Message.UserTypeAdmin)
            {
                return(RedirectToAction(ConstantHelper.constLogin, ConstantHelper.constLogin));
            }
            try
            {
                traceLog.AppendLine("Start: ViewChallenge  controller");
                int challengeId = 0;
                challengeId = Convert.ToInt32(Request.QueryString["id"]);
                ViewWorkoutDetailVM objChallenge = new ViewWorkoutDetailVM();
                if (challengeId > 0)
                {
                    objChallenge = ProgramBL.GetProgramWorkoutById(challengeId);
                }
                return(View(objChallenge));
            }
            catch (Exception ex)
            {
                LogManager.LogManagerInstance.WriteErrorLog(ex);
                return(null);
            }
            finally
            {
                traceLog.AppendLine("ViewChallenge end() : --- " + DateTime.Now.ToLongDateString());
                LogManager.LogManagerInstance.WriteTraceLog(traceLog);
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public static ViewWorkoutDetailVM GetProgramWorkoutById(int id)
        {
            StringBuilder traceLog = new StringBuilder();

            using (LinksMediaContext dataContext = new LinksMediaContext())
            {
                try
                {
                    /*Get challenge detail by challenge*/
                    traceLog.AppendLine("Start: GetProgramWorkoutById() for retrieving challenge by challengeid:" + id);
                    ViewWorkoutDetailVM challenge = (from c in dataContext.Challenge
                                                     join ct in dataContext.ChallengeType
                                                     on c.ChallengeSubTypeId equals ct.ChallengeSubTypeId
                                                     where c.ChallengeId == id
                                                     select new ViewWorkoutDetailVM
                    {
                        ChallengeId = c.ChallengeId,
                        ChallengeName = c.ChallengeName,
                        ChallengeType = ct.ChallengeSubTypeId,
                        ChallengeType_Name = ct.ChallengeSubType,
                        ChallengeSubType_Description = c.Description,
                        ChallengeCategoryNameList = (from trzone in dataContext.ChallengeCategoryAssociations
                                                     join bp in dataContext.ChallengeCategory
                                                     on trzone.ChallengeCategoryId equals bp.ChallengeCategoryId
                                                     where trzone.ChallengeId == c.ChallengeId &&
                                                     trzone.IsProgram == true
                                                     select bp.ChallengeCategoryName).Distinct().ToList <string>(),
                        DifficultyLevel = c.DifficultyLevel,
                        FFChallengeDuration = c.FFChallengeDuration,
                        TempTargetZone = (from trzone in dataContext.TrainingZoneCAssociations
                                          join bp in dataContext.BodyPart
                                          on trzone.PartId equals bp.PartId
                                          where trzone.ChallengeId == c.ChallengeId
                                          select bp.PartName).Distinct().ToList <string>(),
                        TempEquipments = (from trzone in dataContext.ChallengeEquipmentAssociations
                                          join bp in dataContext.Equipments
                                          on trzone.EquipmentId equals bp.EquipmentId
                                          where trzone.ChallengeId == c.ChallengeId
                                          select bp.Equipment).Distinct().ToList <string>()
                    }).FirstOrDefault();
                    if (challenge != null)
                    {
                        var execiseTypelist = (from trzone in dataContext.ETCAssociations
                                               join bp in dataContext.ExerciseTypes
                                               on trzone.ExerciseTypeId equals bp.ExerciseTypeId
                                               where trzone.ChallengeId == challenge.ChallengeId
                                               select bp.ExerciseName).Distinct().ToList <string>();
                        if (execiseTypelist != null && execiseTypelist.Count > 0)
                        {
                            challenge.ExeciseType = string.Join(",", execiseTypelist);
                        }
                        if (challenge.TempEquipments != null && challenge.TempEquipments.Count > 0)
                        {
                            challenge.Equipment = string.Join(", ", challenge.TempEquipments);
                        }
                        challenge.TempEquipments = null;
                        if (challenge.TempTargetZone != null && challenge.TempTargetZone.Count > 0)
                        {
                            challenge.TargetZone = string.Join(", ", challenge.TempTargetZone);
                        }
                        challenge.TempTargetZone = null;
                        /*Get exercise detail for the respective challenge*/
                        List <tblCEAssociation> objCEAssociationList = dataContext.CEAssociation.Where(ce => ce.ChallengeId == id).ToList();
                        List <Exercise>         execisevideoList     = new List <Exercise>();
                        for (int i = 0; i < objCEAssociationList.Count; i++)
                        {
                            tblExercise exercise    = dataContext.Exercise.Find(objCEAssociationList[i].ExerciseId);
                            Exercise    objExercise = new Exercise();
                            if (objCEAssociationList[i].Description != null && objCEAssociationList[i].Description == ConstantHelper.constFFChallangeDescription)
                            {
                                objCEAssociationList[i].Description = string.Empty;
                            }
                            objExercise.ExerciseId             = exercise != null ? exercise.ExerciseId : 0;
                            objExercise.Description            = objCEAssociationList[i].Description;
                            objExercise.ExerciseName           = (exercise != null && !objCEAssociationList[i].IsAlternateExeciseName) ? exercise.ExerciseName : string.Empty;
                            objExercise.VedioLink              = (exercise != null && !objCEAssociationList[i].IsAlternateExeciseName) ? exercise.V720pUrl : string.Empty;
                            objExercise.IsAlternateExeciseName = objCEAssociationList[i].IsAlternateExeciseName;

                            objExercise.AlternateExeciseName = (objCEAssociationList[i].AlternateExeciseName == ConstantHelper.constFFChallangeDescription) ? string.Empty :
                                                               objCEAssociationList[i].AlternateExeciseName;
                            objExercise.Index             = exercise != null ? exercise.Index : string.Empty;
                            objExercise.ExeciseSetRecords = FreeFormChallengeBL.GetFFChallangeExeciseSetById(objCEAssociationList[i].RocordId);
                            execisevideoList.Add(objExercise);
                        }
                        challenge.SetAvailableExerciseVideoList(execisevideoList);
                    }
                    return(challenge);
                }
                catch
                {
                    throw;
                }
                finally
                {
                    traceLog.AppendLine("GetProgramWorkoutById  end() : --- " + DateTime.Now.ToLongDateString());
                    LogManager.LogManagerInstance.WriteTraceLog(traceLog);
                }
            }
        }