private void btnFeedback_Click(object sender, RoutedEventArgs e) { if (!string.IsNullOrEmpty(txtComments.Text)) { try { if (NetworkInterface.GetIsNetworkAvailable()) { UserFeedback userFeedback = new UserFeedback(); userFeedback.AddedByDeveloperId = int.Parse(ApplicationData.User.UserId, CultureInfo.CurrentCulture); userFeedback.AddedDate = DateTime.Now; userFeedback.Description = txtComments.Text; userFeedback.ApplicationType = ApplicationType.Android; this.feedbackRepository.SubmitFeedback(userFeedback, ApplicationData.User.Token); ////AlertMessage("Success", "Feedback entered successfully."); ////ShowToastNotification("Feedback submitted successfully."); if (this.NavigationService.CanGoBack) { PhoneApplicationService.Current.State["ToastNotification"] = "Feedback submitted successfully."; this.NavigationService.GoBack(); } } } catch (Exception) { ShowMessageBox("Insight", "Error in submission of Feedback."); } } else { ShowMessageBox("Insight", "Please enter your comment."); } }
/// <summary> /// Submits the feedback. /// </summary> /// <param name="userFeedback">The user feedback.</param> /// <param name="accessToken">The access token.</param> public async void SubmitFeedback(UserFeedback userFeedback, string accessToken) { if (userFeedback != null && !string.IsNullOrEmpty(accessToken)) { var authenticationHeaderValue = new AuthenticationHeaderValue(AuthorizationScheme, accessToken); await Task.Run(() => this.httpClientHelper.PostResponseData<UserFeedback>(this.GetUri(SubmitFeedbackResource), userFeedback, authenticationHeaderValue)); } }
/// <summary> /// Handles the Click event of the btnSubmit control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param> private void btnSubmit_Click(object sender, EventArgs e) { if (!string.IsNullOrEmpty(txtComments.Text)) { try { if (!IfNetworkAvailable()) { return; } UserFeedback userFeedback = new UserFeedback(); userFeedback.AddedByDeveloperId = int.Parse(ApplicationData.User.UserId, CultureInfo.CurrentCulture); userFeedback.AddedDate = DateTime.Now; userFeedback.Description = txtComments.Text; userFeedback.ApplicationType = ApplicationType.Android; userFeedback.VersionNumber = GetVersionNumber(); this.feedbackRepository.SubmitFeedback(userFeedback, ApplicationData.User.Token); Toast.MakeText(this, GetString(Resource.String.FeedbackSubmissionSucess), ToastLength.Long).Show(); StartActivity(typeof(MainActivity)); } catch (HttpClientException exception) { if (exception.StatusCode == System.Net.HttpStatusCode.RequestTimeout) { AlertMessage(GetString(Resource.String.Error), GetString(Resource.String.FeedbackSubmissionError)); } else { AlertMessage(GetString(Resource.String.Error), GetString(Resource.String.FeedbackSubmissionError)); } } catch (Exception) { AlertMessage(GetString(Resource.String.Error), GetString(Resource.String.FeedbackSubmissionError)); } } else { AlertMessage(GetString(Resource.String.Error), GetString(Resource.String.FeedbackValidation)); } }