private async void LogoTapped(object sender, EventArgs e) { try { Image image = (Image)sender; ExerciseViewModel exercise = (ExerciseViewModel)image.BindingContext; if (exercise.Type == ExerciseType.Normal) { if (await exerciseController.FavoriteExerciseAsync(exercise)) { exercise.Type = ExerciseType.Favorite; SortAndRefresh(); } } else if (exercise.Type == ExerciseType.Favorite) { if (await exerciseController.UnfavoriteExerciseAsync(exercise)) { exercise.Type = ExerciseType.Normal; SortAndRefresh(); } } } catch (ApiException ex) { await DisplayAlert(AppResources.ErrorTitle, LogicHelper.ErrorMessage(ex.ErrorCode), AppResources.DialogOk); } catch (ConnectionException) { await DisplayAlert(AppResources.ErrorTitle, AppResources.ConnectionException, AppResources.DialogOk); } }