private void UpdateExerciseCard() { try { // Update Logic Pending Need to write by mobin ExerciseMaster objExerciseMaster = ExerciseController.GetExerciseMastersByID(ExerciseMasterId); objExerciseMaster.exerciseName = txtExerciseName.Text; objExerciseMaster.exerciseTypeId = Convert.ToInt32(ddlExerciseType.SelectedValue); objExerciseMaster.isPersonalTrainingPackAllow = chkIsPTP.Checked; objExerciseMaster = new ExerciseController().UpdateExerciseMaster(objExerciseMaster); ExerciseCardMaster objExerciseCardMaster = ExerciseController.GetExerciseCardMastersByID(ExerciseCardMasterId); objExerciseCardMaster.bodyTypeId = Convert.ToInt32(ddlBodyType.SelectedValue); objExerciseMaster.exerciseTypeId = Convert.ToInt32(ddlExerciseType.SelectedValue); objExerciseCardMaster.isActive = true; objExerciseCardMaster.exerciseId = objExerciseMaster.ID; if (Convert.ToInt32(ddlExerciseType.SelectedValue) == (int)EnumExerciseType.ArobicExercise) { objExerciseCardMaster.RPM = txtRPM.Text; objExerciseCardMaster.duration = txtDuration.Text; objExerciseCardMaster.Calories = txtCalories.Text; objExerciseCardMaster.Resistence = txtResistence.Text; objExerciseCardMaster.Distance = txtDistance.Text; } objExerciseCardMaster = new ExerciseController().UpdateExerciseCardMaster(objExerciseCardMaster); if (Convert.ToInt32(ddlExerciseType.SelectedValue) == (int)EnumExerciseType.NonArobicExercise) { // delete old ExerciseCardLevelSets new ExerciseController().DeleteAllExrciseCardLevelSets(ExerciseCardMasterId); foreach (var obj in lstExrciseCardLevelSet) { ExrciseCardLevelSet objE = new ExrciseCardLevelSet(); //ExerciseController.GetExrciseCardLevelSetsByCardID(ExerciseCardMasterId); objE.levelId = obj.levelId; objE.set1 = obj.set1; objE.set2 = obj.set2; objE.set3 = obj.set3; objE.set4 = obj.set4; objE.exrciseCardId = objExerciseCardMaster.ID; new ExerciseController().InsertExrciseCardLevelSet(objE); // insert new updated ExerciseCardLevelSets // InsertExerciseCard(); } } } catch (Exception ex) { throw ex; } }
private void BindExerciseCardValues() { try { ExerciseCardMaster objExerciseCardMaster = ExerciseController.GetExerciseCardMastersByID(ExerciseCardMasterId); var lstSetLevels = ExerciseController.GetExrciseCardLevelSetsByExerciseCardMaterId(ExerciseCardMasterId); List <ExrciseCardLevelSet> lstTemp = new List <ExrciseCardLevelSet>(); foreach (var obj in lstSetLevels) { ExrciseCardLevelSet objE = new ExrciseCardLevelSet(); objE.levelId = obj.levelId; objE.set1 = obj.set1; objE.set2 = obj.set2; objE.set3 = obj.set3; objE.set4 = obj.set4; lstTemp.Add(objE); } lstExrciseCardLevelSet = lstTemp; BindTempLevels(); txtCalories.Text = objExerciseCardMaster.Calories; txtDuration.Text = objExerciseCardMaster.duration; txtExerciseName.Text = objExerciseCardMaster.ExerciseMaster.exerciseName; txtResistence.Text = objExerciseCardMaster.Resistence; txtRPM.Text = objExerciseCardMaster.RPM; txtDistance.Text = objExerciseCardMaster.Distance; ddlBodyType.SelectedValue = objExerciseCardMaster.bodyTypeId == null ? "1" : objExerciseCardMaster.bodyTypeId.ToString(); ddlExerciseType.SelectedValue = objExerciseCardMaster.exerciseTypeId == null ? "1" : objExerciseCardMaster.exerciseTypeId.ToString(); ExerciseMasterId = (long)objExerciseCardMaster.exerciseId; if (objExerciseCardMaster.exerciseTypeId == (int)EnumExerciseType.ArobicExercise) { pnlArobic.Visible = true; pnlNonArobic.Visible = false; } else { pnlNonArobic.Visible = true; pnlArobic.Visible = false; pnlNonArobicView.Visible = true; pnlNonArobicEdit.Visible = false; } BindTempLevels(); } catch (Exception ex) { throw ex; } }
private void InsertExerciseCard() { try { if (SetExerciseMode == "Insert") { ExerciseMaster objExerciseMaster = new ExerciseMaster(); objExerciseMaster.exerciseName = txtExerciseName.Text; objExerciseMaster.exerciseTypeId = Convert.ToInt32(ddlExerciseType.SelectedValue); objExerciseMaster.isPersonalTrainingPackAllow = chkIsPTP.Checked; objExerciseMaster.clubId = LoginUser.ClubId; objExerciseMaster = new ExerciseController().InsertExerciseMaster(objExerciseMaster); ExerciseCardMaster objExerciseCardMaster = new ExerciseCardMaster(); objExerciseCardMaster.bodyTypeId = Convert.ToInt32(ddlBodyType.SelectedValue); objExerciseCardMaster.exerciseTypeId = Convert.ToInt32(ddlExerciseType.SelectedValue); objExerciseCardMaster.isActive = true; objExerciseCardMaster.exerciseId = objExerciseMaster.ID; if (Convert.ToInt32(ddlExerciseType.SelectedValue) == (int)EnumExerciseType.ArobicExercise) { objExerciseCardMaster.RPM = txtRPM.Text; objExerciseCardMaster.duration = txtDuration.Text; objExerciseCardMaster.Calories = txtCalories.Text; objExerciseCardMaster.Resistence = txtResistence.Text; objExerciseCardMaster.Distance = txtDistance.Text; } objExerciseCardMaster = new ExerciseController().InsertExerciseCardMaster(objExerciseCardMaster); if (Convert.ToInt32(ddlExerciseType.SelectedValue) == (int)EnumExerciseType.NonArobicExercise) { foreach (var obj in lstExrciseCardLevelSet) { ExrciseCardLevelSet objE = new ExrciseCardLevelSet(); objE.levelId = obj.levelId; objE.set1 = obj.set1; objE.set2 = obj.set2; objE.set3 = obj.set3; objE.set4 = obj.set4; objE.exrciseCardId = objExerciseCardMaster.ID; new ExerciseController().InsertExrciseCardLevelSet(objE); } } } } catch (Exception ex) { throw ex; } }
public ExerciseCardMaster InsertExerciseCardMaster(ExerciseCardMaster objExerciseCardMaster) { try { objExerciseCardMaster.insertDate = DateTime.Now; //objExerciseCardMaster.isActive = true; objExerciseCardMaster.isDeleted = false; using (var context = new FitnessCenterEntities()) { context.ExerciseCardMasters.AddObject(objExerciseCardMaster); context.SaveChanges(); return(objExerciseCardMaster); } } catch (Exception ex) { throw ex; } }
public ExerciseCardMaster UpdateExerciseCardMaster(ExerciseCardMaster objExerciseCardMaster) { try { objExerciseCardMaster.updateDate = DateTime.Now; using (var context = new FitnessCenterEntities()) { context.ExerciseCardMasters.Attach(context.ExerciseCardMasters.Single(varC => varC.ID == objExerciseCardMaster.ID)); context.ExerciseCardMasters.ApplyCurrentValues(objExerciseCardMaster); context.SaveChanges(); return(objExerciseCardMaster); } } catch (Exception ex) { throw ex; } }