public MainPage(AuthenticationResult result) { InitializeComponent(); this.authenticationResult = result; NavigationPage.SetHasNavigationBar(this, false); InitClaimList(); listView.ItemTapped += async(sender, e) => { listView.SelectedItem = null;//clear android select color ClaimViewModel vmodel = (ClaimViewModel)e.Item; ClaimModel claim = claimListSource.Find(x => x.Id.Equals(vmodel.Id)); if (claim != null) { await Navigation.PushAsync(new ClaimDetailPage(claim)); } }; if (result != null) { string name = result.User.Name; if (name.Contains(" ")) { name = name.Substring(0, name.IndexOf(" ")); } this.userNameLabel.Text = $"Hello {name}"; } InitGridView(); }
private async Task <SubmitCaseRsp> CallQueue(ClaimModel claim) { string json = JsonConvert.SerializeObject(claim); HttpResponseMessage response = await HttpUtil.PostJsonAsync(json, Settings.QueueUrl, _authenticationResult.Token); if (response.IsSuccessStatusCode) { string responseStr = await response.Content.ReadAsStringAsync(); char[] charsToTrim = { '\"' }; responseStr = responseStr.Trim(charsToTrim).Replace("\\\"", "\""); SubmitCaseRsp value = JsonConvert.DeserializeObject <SubmitCaseRsp>(responseStr); return(value); } return(null); }
public void AddNewClaim(ClaimModel cl) { this.claimListSource.Insert(0, cl); UpdateClaimViewList(); }
private async void OnSubmitClaimButtonClicked(object sender, EventArgs e) { try { if (_mediaFile != null) { using (var scope = new ActivityIndicatorScope(activityIndicator, activityIndicatorPanel, true)) { HttpResponseMessage response = await HttpUtil.PostImageAsync(_mediaFile, Settings.UploadImageUrl, _authenticationResult.Token); if (response.IsSuccessStatusCode) { string responseURL = await response.Content.ReadAsStringAsync(); char[] charsToTrim = { '\"' }; responseURL = responseURL.Trim(charsToTrim); Random rnd = new Random(); string claimName = rnd.Next(15000, 16000).ToString(); ClaimModel claim = new ClaimModel { Id = Guid.NewGuid().ToString(), Name = claimName, Status = "Submitted", ClaimDateTime = this.datePicker.Date, ClaimDescription = this.claimDescriptionEditor.Text, ImageUrl = responseURL, Tag = "" }; SubmitCaseRsp ret = await CallQueue(claim); if (ret != null && ret.result) { _parentPage.AddNewClaim(claim); await DisplayAlert("Thank you", "Your claim is being processed.", "Ok"); await Navigation.PopAsync(); } else { await DisplayAlert("Please resubmit", "Photo doesn't appear to match the claim.", "Ok"); } } else { // If the call failed with access denied, show the user an error indicating they might need to sign-in again. if (response.StatusCode == System.Net.HttpStatusCode.Unauthorized) { await DisplayAlert("Unauthorized", "Please login again, then new claim works well again", "Ok"); await Navigation.PopToRootAsync(); } else { await DisplayAlert("Error", response.StatusCode.ToString(), "Ok"); } } } } } catch (Exception ex) { Utils.TraceException("Image upload failed", ex); await DisplayAlert("Image upload failed", "Image upload failed. Please try again later", "Ok"); } }
public ClaimDetailPage(ClaimModel model) { InitializeComponent(); this.BindingContext = model; InitGridView(); }