public void addSets(BL_routine routine, int routineID, int personID) { try { // making new list routine list List <BL_routine> routineList = new List <BL_routine>(); { // adding routines to the list routineList.Add(routine); } // making ints for routineid and personid int personIDBL = personID; int routineIDBL = routineID; // making new instance of object routine workout BL_routineWorkout routineWorkoutList = new BL_routineWorkout(); // getting the lift of exercise based on the routine passing person id and routine id routineWorkoutList.routineWList = _mapper.map(routineWData.listAllRoutineWorkout(personIDBL, routineID)); //making the new list of routine exercise List <BL_routineWorkout> BL_routineWList = new List <BL_routineWorkout>(); { for (int i = 0; i < routineWorkoutList.routineWList.Count(); i++) { // adding exercise to routineWlist BL_routineWList.Add(routineWorkoutList.routineWList[i]); } } int sets = 0; // setting sets to 0 int reps = 0; // setting reps to 0 int exercise = BL_routineWList.Count; // using the the count of routine list and setting as exercise routineWorkoutList.FK_routineWorkoutID = routine.routineID; // for loop for going through the list of routines for (int i = 0; i < BL_routineWList.Count(); i++) { // adding routine sets to the total sets sets += BL_routineWList[i].routineWSets; // adding reps to total reps reps += BL_routineWList[i].routineWReps; } // setting sets and reps to routine sets and reps routine.totalSets = sets; routine.totalReps = reps; routine.totalExercise = exercise; // calling data access to update the total sets and reps routineData.updateSetsReps(_mapper.map(routine), routineIDBL); } // log error catch (Exception _error) { // putting errors into a text file _logger.logError(_error); } }
public BL_routine map(routineDAO _routineToMap) { BL_routine _routineRetMod = new BL_routine(); _routineRetMod.routineID = _routineToMap.routineID; _routineRetMod.routineName = _routineToMap.routineName; _routineRetMod.FK_personID = _routineToMap.FK_personID; _routineRetMod.login = _routineToMap.login; _routineRetMod.totalSets = _routineToMap.totalSets; _routineRetMod.totalReps = _routineToMap.totalReps; _routineRetMod.totalExercise = _routineToMap.totalExercise; return(_routineRetMod); }
public List <BL_routine> map(List <routineDAO> _dataRoutine) { List <BL_routine> _pressRoutine = new List <BL_routine>(); foreach (routineDAO _dRoutine in _dataRoutine) { BL_routine _pRoutine = new BL_routine(); _pRoutine.routineID = _dRoutine.routineID; _pRoutine.routineName = _dRoutine.routineName; _pRoutine.FK_personID = _dRoutine.FK_personID; _pRoutine.login = _dRoutine.login; _pRoutine.totalSets = _dRoutine.totalSets; _pRoutine.totalReps = _dRoutine.totalReps; _pRoutine.totalExercise = _dRoutine.totalExercise; _pressRoutine.Add(_pRoutine); } return(_pressRoutine); }