private async void Dislike_Click(object sender, RoutedEventArgs e) { stDislikes.IsEnabled = false; ApiResponse <CountSchema> result; if (CurrentPostData.Dislikes.MyCount == 0) { result = await PostApi.AddDislike( SettingsManager.PersistentSettings.CurrentUser.Token, CurrentPostData.Id) .ConfigureAwait(true); } else { result = await PostApi.RemoveDislike( SettingsManager.PersistentSettings.CurrentUser.Token, CurrentPostData.Id) .ConfigureAwait(true); } if (result.IsError) { await DialogManager.ShowErrorDialog(result.Message) .ConfigureAwait(true); stDislikes.IsEnabled = true; return; } if (CurrentPostData.Dislikes.MyCount == 0) { ++CurrentPostData.Dislikes.MyCount; } else { --CurrentPostData.Dislikes.MyCount; } CurrentPostData.Dislikes.TotalCount = result.Data.Count; stDislikes.IsEnabled = true; }
private async void Dislike_Click(object sender, RoutedEventArgs e) { DislikeButton.IsEnabled = false; try { ApiResponse <CountSchema> result; if (CurrentPostData.Dislikes.MyCount == 0) { result = await PostApi.AddDislike( SettingsManager.PersistentSettings.CurrentUser.Token, CurrentPostData.Id) .ConfigureAwait(true); } else { result = await PostApi.RemoveDislike( SettingsManager.PersistentSettings.CurrentUser.Token, CurrentPostData.Id) .ConfigureAwait(true); } if (result.IsError) { if (string.Compare(result.Message, "id is not defined", StringComparison.OrdinalIgnoreCase) == 0) { if (CurrentPostData.Dislikes.MyCount == 0) { ++CurrentPostData.Dislikes.MyCount; ++CurrentPostData.Dislikes.TotalCount; } else { --CurrentPostData.Dislikes.MyCount; --CurrentPostData.Dislikes.TotalCount; } return; } await DialogManager.ShowErrorDialog(result.Message) .ConfigureAwait(true); return; } if (CurrentPostData.Dislikes.MyCount == 0) { ++CurrentPostData.Dislikes.MyCount; } else { --CurrentPostData.Dislikes.MyCount; } CurrentPostData.Dislikes.TotalCount = result.Data.Count; } finally { DislikeButton.IsEnabled = true; } }