public async Task UploadPhotoID(string requestType, DocumentType documentType) { try { CheckConnectivity(); string imageByte = ""; imageByte = Convert.ToBase64String(PhotoIdStream.ToArray()); IsUploadingPhotoId = true; CanUploadPhoto = false; var profileimage = new DocumentUploadModel { ImageByte = imageByte, NUBAN = GlobalStaticFields.Customer.ListOfAllAccounts?.FirstOrDefault()?.nuban, FileType = "jpg", ReferenceID = Utilities.GenerateReferenceId(), RequestType = requestType, DocumentType = documentType }; var apirequest = new ApiRequest(); string msg = ""; string content = ""; var request = await apirequest.Post <DocumentUploadModel>(profileimage, "", URLConstants.SwitchApiLiveBaseUrl, "Switch/UploadMandate", "ProfileVerificationDetailsPageViewModel"); if (request.IsSuccessStatusCode) { content = await request.Content.ReadAsStringAsync(); PhotoIDUploadedColor = Color.FromRgb(90, 200, 250); PhotoIdButtonText = "Retake"; // ProfileImageSource = ImageSource.FromUri(new Uri($"{URLConstants.SwitchUrl}upload/{GlobalStaticFields.Customer.UserID}.jpg")); } else { content = await request.Content.ReadAsStringAsync(); } if (!string.IsNullOrWhiteSpace(content)) { content = content.JsonCleanUp(); Utilities.ShowToast(content); } } catch (Exception ex) { } finally { IsUploadingPhotoId = false; CanUploadPhoto = true; } }
public async Task SaveUpload(string requestType, DocumentType documentType) { try { CheckConnectivity(); string imageByte = ""; switch (documentType) { case DocumentType.InternationalPassport: case DocumentType.DriversLicense: case DocumentType.NationalIDCard: imageByte = Convert.ToBase64String(PhotoIdStream.ToArray()); IsUploadingPhotoId = true; break; case DocumentType.UtilityBill: case DocumentType.RentReceipt: case DocumentType.TelephoneBill: imageByte = Convert.ToBase64String(DocumentStream.ToArray()); IsAddressVerifying = true; break; default: break; } var profileimage = new DocumentUploadModel { ImageByte = imageByte, NUBAN = GlobalStaticFields.Customer.ListOfAllAccounts?.FirstOrDefault()?.nuban, FileType = "jpg", ReferenceID = Utilities.GenerateReferenceId(), RequestType = requestType, DocumentType = documentType }; var apirequest = new ApiRequest(); string msg = ""; string content = ""; var request = await apirequest.Post <DocumentUploadModel>(profileimage, "", URLConstants.SwitchApiLiveBaseUrl, "Switch/UploadMandate", "ProfileVerificationDetailsPageViewModel"); if (request.IsSuccessStatusCode) { content = await request.Content.ReadAsStringAsync(); switch (documentType) { case DocumentType.InternationalPassport: case DocumentType.DriversLicense: case DocumentType.NationalIDCard: // IsUploadingPhotoId = true; break; case DocumentType.UtilityBill: case DocumentType.RentReceipt: case DocumentType.TelephoneBill: // IsAddressVerifying = true; break; default: break; } // ProfileImageSource = ImageSource.FromUri(new Uri($"{URLConstants.SwitchUrl}upload/{GlobalStaticFields.Customer.UserID}.jpg")); } else { content = await request.Content.ReadAsStringAsync(); } if (!string.IsNullOrWhiteSpace(content)) { content = content.JsonCleanUp(); Utilities.ShowToast(content); } } catch (Exception ex) { } finally { switch (documentType) { case DocumentType.InternationalPassport: case DocumentType.DriversLicense: case DocumentType.NationalIDCard: IsUploadingPhotoId = false; break; case DocumentType.UtilityBill: case DocumentType.RentReceipt: case DocumentType.TelephoneBill: IsAddressVerifying = false; break; default: break; } } }