/// <summary> /// speichert ein WorkoutDayModel in der Datenbank ab. Wenn das Objekt bereits in der DB existiert, dann /// wird es geaendert, ansonsten neu angelegt. /// </summary> /// <param name="model">Das WorkoutDayModel-Objekt das gespeichert werden soll</param> public void SaveWorkoutDay(ml_WorkoutDay workoutDay) { if (workoutDay.ID <= 0) { _repo.Insert(workoutDay); } else { _repo.Update(workoutDay); } }
private IEnumerable<ml_WorkoutDay> GetWorkoutsListFromFormData() { var workoutDays = new List<ml_WorkoutDay>(); int numSets = -1; int numReps = -1; for (int i = 0; i < _exercises.Length; i++) { if (!Int32.TryParse(_sets[i], out numSets) || numSets <= 0) throw new InvalidOperationException("The form data is not valid."); if (!Int32.TryParse(_reps[i], out numReps) || numReps <= 0) throw new InvalidOperationException("The form data is not valid."); var workoutDayModel = new ml_WorkoutDay(); workoutDayModel.CRDT = workoutDayModel.LUDT = DateTime.Now; workoutDayModel.Day = (byte)_dayIndex; workoutDayModel.Exercise = _exercises[i]; workoutDayModel.Reps = numReps; workoutDayModel.Sets = (byte)numSets; workoutDayModel.SortOrder = i; workoutDayModel.WorkoutPlanID = _workoutID; workoutDays.Add(workoutDayModel); } return workoutDays; }