/// <summary> /// Change Exercise Status /// </summary> /// <param name="exerciseId"></param> /// <param name="operationId"></param> /// <returns></returns> public static ExerciseStatusVM ChangeExerciseStatus(int exerciseId, int operationId) { StringBuilder traceLog = new StringBuilder(); using (LinksMediaContext dataContext = new LinksMediaContext()) { try { ExerciseStatusVM objExerciseStatusVM = new ExerciseStatusVM(); traceLog.AppendLine("Start: ChangeExerciseStatus---- " + DateTime.Now.ToLongDateString()); if (exerciseId > 0) { tblExercise exercise = dataContext.Exercise.Where(ex => ex.ExerciseId == exerciseId).FirstOrDefault(); switch (operationId) { case 1: { exercise.ExerciseStatus = 1; objExerciseStatusVM.OperationId = operationId; objExerciseStatusVM.OperationResultId = 1; } break; case 2: { exercise.ExerciseStatus = 2; objExerciseStatusVM.OperationId = operationId; objExerciseStatusVM.OperationResultId = 2; } break; case 3: { if (dataContext.CEAssociation.Any(ex => ex.ExerciseId == exerciseId)) { exercise.ExerciseStatus = 2; objExerciseStatusVM.OperationResultId = -1; } else { exercise.ExerciseStatus = 3; objExerciseStatusVM.OperationResultId = 1; } objExerciseStatusVM.OperationId = operationId; } break; } dataContext.SaveChanges(); } return(objExerciseStatusVM); } finally { traceLog.AppendLine("End ChangeExerciseStatus : --- " + DateTime.Now.ToLongDateString()); LogManager.LogManagerInstance.WriteTraceLog(traceLog); } } }
private void BtnAdd_Click(object sender, EventArgs e) { try { var db = new SQLiteConnection(dpPath); db.CreateTable <tblExercise>(); tblExercise tbl = new tblExercise(); tbl.IDDeasease = txtDiseaseID.Text; tbl.ToDo = txtToDO.Text; tbl.Minutes = txtMinutesToDo.Text; tbl.Difficulty = txtDifficulty.Text; tbl.BodyPart = txtBodyPart.Text; db.Insert(tbl); Toast.MakeText(this, "Record Added Successfully...,", ToastLength.Short).Show(); } catch (Exception i) { Toast.MakeText(this, i.ToString(), ToastLength.Short).Show(); } }
/// <summary> /// Add Exercise SproutData /// </summary> /// <param name="updateExecise"></param> public static void AddExerciseSproutData(UpdateExerciseSproutLink updateExecise) { StringBuilder traceLog = new StringBuilder(); using (LinksMediaContext dataContext = new LinksMediaContext()) { try { traceLog.AppendLine("Start: AddExerciseSproutData---- " + DateTime.Now.ToLongDateString()); if (updateExecise != null) { tblExercise uploadExecise = new tblExercise(); if (uploadExecise != null) { string vidurlformat = "https://api-files.sproutvideo.com/file/{0}/{1}/{2}.mp4"; string v1 = updateExecise.V1080pUrl; string v5 = updateExecise.V240pUrl; string v4 = updateExecise.V360pUrl; string v3 = updateExecise.V480pUrl; string v2 = updateExecise.V720pUrl; if (string.IsNullOrEmpty(Convert.ToString(v2))) { if (string.IsNullOrEmpty(v3)) { if (string.IsNullOrEmpty(v4)) { uploadExecise.V720pUrl = v5; } else { uploadExecise.V720pUrl = v4; } } else { uploadExecise.V720pUrl = v3; } } else { uploadExecise.V720pUrl = v2; } if (string.IsNullOrEmpty(v1)) { uploadExecise.V240pUrl = string.Format(vidurlformat, updateExecise.VideoId, updateExecise.SecuryId, "1080"); } if (string.IsNullOrEmpty(v2) && string.IsNullOrEmpty(updateExecise.V720pUrl)) { uploadExecise.V720pUrl = string.Format(vidurlformat, updateExecise.VideoId, updateExecise.SecuryId, "240"); } if (string.IsNullOrEmpty(v3)) { uploadExecise.V240pUrl = string.Format(vidurlformat, updateExecise.VideoId, updateExecise.SecuryId, "480"); } if (string.IsNullOrEmpty(v4)) { uploadExecise.V240pUrl = string.Format(vidurlformat, updateExecise.VideoId, updateExecise.SecuryId, "360"); } if (string.IsNullOrEmpty(v5)) { uploadExecise.V240pUrl = string.Format(vidurlformat, updateExecise.VideoId, updateExecise.SecuryId, "240"); } uploadExecise.ThumnailUrl = updateExecise.ThumnailUrl; uploadExecise.SecuryId = updateExecise.SecuryId; uploadExecise.VideoId = updateExecise.VideoId; uploadExecise.IsUpdated = true; uploadExecise.VideoLink = updateExecise.VideoLink; uploadExecise.VideoId = updateExecise.VideoId; uploadExecise.ExerciseName = updateExecise.ExerciseName; uploadExecise.Index = updateExecise.Index; uploadExecise.IsActive = updateExecise.IsActive; uploadExecise.Description = updateExecise.Description; uploadExecise.VideoLink = updateExecise.VideoLink; uploadExecise.TrainerID = updateExecise.TrainerID; uploadExecise.TeamID = updateExecise.TeamID; uploadExecise.ExerciseStatus = 1; dataContext.Exercise.Add(uploadExecise); dataContext.SaveChanges(); } } } catch { throw; } finally { traceLog.AppendLine("End AddExerciseSproutData : --- " + DateTime.Now.ToLongDateString()); LogManager.LogManagerInstance.WriteTraceLog(traceLog); } } }
/// <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); } } }