public GetAllDocumentByCustomerIdResponse getDocuments(GetMobileCustomerByIDRequest request, string token) { GetAllDocumentByCustomerIdResponse res = new GetAllDocumentByCustomerIdResponse(); try { using (var client = new HttpClient()) { client.BaseAddress = new Uri(ConstantData.ApiURL.ToString() + "CustomerMobile/GetAllDocumentByCustomerId"); client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token); var myContent = JsonConvert.SerializeObject(request); var buffer = Encoding.UTF8.GetBytes(myContent); var byteContent = new ByteArrayContent(buffer); byteContent.Headers.ContentType = new MediaTypeHeaderValue("application/json"); var response = client.PostAsync(client.BaseAddress, byteContent).Result; if (response.IsSuccessStatusCode) { var responseStream = response.Content.ReadAsStringAsync().Result; res = JsonConvert.DeserializeObject <GetAllDocumentByCustomerIdResponse>(responseStream); } } } catch (Exception ex) { throw ex; } return(res); }
private GetAllDocumentByCustomerIdResponse getDocuments(GetMobileCustomerByIDRequest request) { GetAllDocumentByCustomerIdResponse response = null; LoginController controller = new LoginController(); response = controller.getDocuments(request, token); return(response); }
public MyDouments() { InitializeComponent(); request = new GetMobileCustomerByIDRequest(); response = null; token = App.Current.Properties["currentToken"].ToString(); request.CustomerId = (int)App.Current.Properties["CustomerId"]; RegDocs = new List <Document>(); InsDocs = new List <Document>(); otherDocs = new List <Document>(); }
public GetAllDocumentByCustomerIdResponse getDocuments(GetMobileCustomerByIDRequest request, string token) { GetAllDocumentByCustomerIdResponse response = new GetAllDocumentByCustomerIdResponse(); try { response = loginservice.getDocuments(request, token); } catch (Exception ex) { throw ex; } return(response); }
protected override async void OnAppearing() { base.OnAppearing(); if (PopupNavigation.Instance.PopupStack.Count > 0) { await PopupNavigation.Instance.PopAllAsync(); } bool busy = false; if (!busy) { try { busy = true; await PopupNavigation.Instance.PushAsync(new LoadingPopup("Loading details...")); await Task.Run(async() => { try { response = getDocuments(request); } catch (Exception ex) { await PopupNavigation.Instance.PushAsync(new Error_popup(ex.Message)); } }); } finally { busy = false; if (PopupNavigation.Instance.PopupStack.Count == 1) { await PopupNavigation.Instance.PopAllAsync(); } if (PopupNavigation.Instance.PopupStack.Count > 1) { if (PopupNavigation.Instance.PopupStack[PopupNavigation.Instance.PopupStack.Count - 1].GetType() != typeof(ErrorWithClosePagePopup)) { await PopupNavigation.Instance.PopAllAsync(); } } if (response != null) { if (response.message.ErrorCode == "200") { //sortedList = response.DocList.OrderByDescending(x => x.DocumentId).ToList(); //fixtoRecentListView(sortedList); RegDocs = new List <Document>(); InsDocs = new List <Document>(); otherDocs = new List <Document>(); float regSize = 0; float insSize = 0; float docSize = 0; foreach (Document d in response.DocList) { if (d.Side != null) { if (d.Side.ToLower().Contains("vehicle_registration")) { RegDocs.Add(d); regSize += d.FileSize; } else if (d.Side.ToLower().Contains("insurance")) { InsDocs.Add(d); insSize += d.FileSize; } else { otherDocs.Add(d); docSize += d.FileSize; } } else { otherDocs.Add(d); docSize += d.FileSize; } } if (RegDocs != null) { float RegSizeKB = regSize / 1024; float RegSizeMB = RegSizeKB / 1024; if (RegSizeMB > 1) { imageSize.Text = RegSizeMB.ToString("0.00"); imageSizeUnit.Text = " MB"; } else { imageSize.Text = RegSizeKB.ToString("0.00"); imageSizeUnit.Text = " KB"; } imFileCount.Text = RegDocs.Count.ToString(); } if (InsDocs != null) { float InsSizeKB = insSize / 1024; float InsSizeMB = InsSizeKB / 1024; if (InsSizeMB > 1) { fileSize.Text = InsSizeMB.ToString("0.00"); fileSizeUnit.Text = " MB"; } else { fileSize.Text = InsSizeKB.ToString("0.00"); fileSizeUnit.Text = " KB"; } othFilesCount.Text = InsDocs.Count.ToString(); } if (otherDocs != null) { float docSizeKB = docSize / 1024; float docSizeMB = docSizeKB / 1024; if (docSizeMB > 1) { otherFileSize.Text = docSizeMB.ToString("0.00"); otherFileSizeUnit.Text = " MB"; } else { otherFileSize.Text = docSizeKB.ToString("0.00"); otherFileSizeUnit.Text = " KB"; } othDocFilesCount.Text = otherDocs.Count.ToString(); } } else { await PopupNavigation.Instance.PushAsync(new Error_popup(response.message.ErrorMessage)); } } else { await PopupNavigation.Instance.PushAsync(new Error_popup("Sorry, Something went wrong, Please try again.")); } } } }