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_routineWorkout map(routineWorkoutDAO _routineWorkoutToMap) { // put all the info in business logic routine exerices from databases BL_routineWorkout _routineWorkoutToReturn = new BL_routineWorkout(); _routineWorkoutToReturn.routineWorkoutID = _routineWorkoutToMap.routineWorkoutID; _routineWorkoutToReturn.FK_exerciseID = _routineWorkoutToMap.FK_exerciseID; _routineWorkoutToReturn.FK_routineWorkoutID = _routineWorkoutToMap.FK_routineWorkoutID; _routineWorkoutToReturn.routineWSets = _routineWorkoutToMap.routineWSets; _routineWorkoutToReturn.routineWReps = _routineWorkoutToMap.routineWReps; _routineWorkoutToReturn.routineWRest = _routineWorkoutToMap.routineWRest; return(_routineWorkoutToReturn); }
public List <BL_routineWorkout> map(List <routineWorkoutDAO> _dataRoutineWorkout) { List <BL_routineWorkout> _pressRoutineWorkout = new List <BL_routineWorkout>(); foreach (routineWorkoutDAO _dRoutineWorkout in _dataRoutineWorkout) { BL_routineWorkout _pRoutineWorkout = new BL_routineWorkout(); _pRoutineWorkout.routineWorkoutID = _dRoutineWorkout.routineWorkoutID; _pRoutineWorkout.FK_exerciseID = _dRoutineWorkout.FK_exerciseID; _pRoutineWorkout.FK_routineWorkoutID = _dRoutineWorkout.FK_routineWorkoutID ; _pRoutineWorkout.routineWSets = _dRoutineWorkout.routineWSets; _pRoutineWorkout.routineWReps = _dRoutineWorkout.routineWReps; _pRoutineWorkout.routineWRest = _dRoutineWorkout.routineWRest; _pressRoutineWorkout.Add(_pRoutineWorkout); } return(_pressRoutineWorkout); }