private void NextSet(object o) { if (CurrentSet != null) { SaveCurrent(); int nextNumber = CurrentSet.OrdinalNumber + 1; Set nextSet = Sets.SingleOrDefault(x => x.OrdinalNumber == nextNumber); if (nextSet != null) { CurrentSet = new SetVM(nextSet); return; } if (nextNumber == LastSet.OrdinalNumber) { CurrentSet = LastSet; FinishButtonState = true; return; } LastSet = CreateNewSet(nextNumber); FinishCurrentSet(); FinishButtonState = true; CurrentSet = LastSet; return; } LastSet = CreateNewSet(1); CurrentSet = LastSet; }
public ExecutePageVM(long id) { _trainingExercise = RepoTrainingExercise.Instance.FindById(id); _exercise = RepoExercise.Instance.FindById(_trainingExercise.IdExecise); _stateFactory = new PageStateFactory(this); _state = _stateFactory.GetState(); if (Status == TrainingExerciseStatus.Created) { Start(); return; } InitializeHistoryOnDemand(); if (Sets.Count != 0) { int lastOrdinal = Sets.Max(x => x.OrdinalNumber); CurrentSet = LastSet = new SetVM(Sets.SingleOrDefault(x => x.OrdinalNumber == lastOrdinal)); FinishButtonState = true; } _state.Initialize(); }
private void PreviousSet(object o) { if (CurrentSet != null) { SaveCurrent(true); int previousNumber = CurrentSet.OrdinalNumber - 1; Set previousSet = Sets.SingleOrDefault(x => x.OrdinalNumber == previousNumber); if (previousSet != null) { CurrentSet = new SetVM(previousSet); } } }