public async Task Recalc() { var workoutsList = await _workoutsRepository.AllAsync(); foreach (var workout in workoutsList) { workout.Trophies = _workoutRules.GetTrophies(workout); await _workoutsRepository.SaveAsync(workout); } App.TotalTrophies = await _workoutsRepository.GetTotalTrophies(); }
public async Task OnSave() { if (await Validate()) { // invalidate TotalTrophies App.TotalTrophies = null; var workout = new Workout { WorkoutId = this.WorkoutId, ExerciseId = Exercise.ExerciseId, Created = this.Created, Notes = this.Notes, Reps = this.Reps, Weight = _units.GetMetric(App.Settings.IsMetric, this.Weight), PreviousReps = this.PreviousReps, PreviousWeight = _units.GetMetric(App.Settings.IsMetric, this.PreviousWeight), TargetReps = this.TargetReps, TargetWeight = _units.GetMetric(App.Settings.IsMetric, this.TargetWeight), }; workout.Trophies = _workoutRules.GetTrophies(workout); var isPersisted = WorkoutId > 0; WorkoutId = await _workoutsRepository.SaveAsync(workout); _messagingService.Send(this, Messages.ItemChanged, workout); AppResources.WorkoutSaved.ToToast(ToastNotificationType.Success); if (App.Settings.RestTimerAutoStart && !isPersisted) { await _navigationService.PopAsync(); if (!RestTimerItem.IsRunning) { var parameters = new NavigationParameters { { "StartImmediately", true }, { "RestTimerItem", RestTimerItem } }; await _navigationService.NavigateToHierarchical <RestTimerViewModel>(parameters); } } else { await _navigationService.PopAsync(); } } }