public OtherInformationPage(CustomerReview customer, CustomerImages images) { InitializeComponent(); this.customer = customer; licenceIssueDate.MaximumDate = DateTime.Now; licenceExpiryDate.MinimumDate = DateTime.Now; _token = App.Current.Properties["currentToken"].ToString(); GetAllStateForMobileRequest stateRequest = new GetAllStateForMobileRequest(); List <string> stateList = new List <string>(); stateRequest.CountryID = (int)customer.CountryId; stateResponse = getStates(stateRequest, _token); if (stateResponse.stateList.Count > 0) { foreach (State s in stateResponse.stateList) { stateList.Add(s.StateCode); } ; } licenceStatePicker.ItemsSource = stateList; imageMobileRequest = new UploadCustomerImageMobileRequest(); imageMobileResponse = null; this.images = images; licExpireDateSelected = false; licIssueDateSelected = false; licfrontIamgeStat = new CustomerImages(); licBackIamgeStat = new CustomerImages(); LicenceImagesRequest = new AddLicenceImagesRequest(); licenceImageResponse = null; }
public editPrrofilePhotoPage() { InitializeComponent(); images = new CustomerImages(); customerID = (int)App.Current.Properties["CustomerId"]; _token = App.Current.Properties["currentToken"].ToString(); imageMobileRequest = new UploadCustomerImageMobileRequest(); imageMobileResponse = null; }
public UploadCustomerImageMobileResponse addCustomerImage(UploadCustomerImageMobileRequest imageMobileRequest, string _token) { UploadCustomerImageMobileResponse response = null; try { response = registerservice.addCustomerImage(imageMobileRequest, _token); } catch (Exception ex) { throw ex; } return(response); }
public editPrrofilePhotoPage(CustomerImages images) { InitializeComponent(); customerID = (int)App.Current.Properties["CustomerId"]; _token = App.Current.Properties["currentToken"].ToString(); imageMobileRequest = new UploadCustomerImageMobileRequest(); imageMobileResponse = null; this.images = images; selectedImage.Source = ImageSource.FromStream(() => new MemoryStream(Convert.FromBase64String(images.Base64))); _base64Image = images.Base64; UploadedDate = DateTime.Now; PhysicalPath = images.PhysicalPath; if (images.Base64 != null) { PhotoFrame.IsVisible = true; SaveBtn.IsVisible = true; cancelBtn.IsVisible = true; } }
private void SaveBtn_Clicked(object sender, EventArgs e) { CustomerImages customerImages = new CustomerImages(); RegisterController registerController = new RegisterController(); images.UploadedDate = UploadedDate; images.Base64 = _base64Image; images.PhysicalPath = PhysicalPath; if (images != null && customerID > 0) { imageMobileRequest.custImag = images; imageMobileRequest.custImag.CustomerID = customerID; imageMobileRequest.custImag.ImageID = customerID; imageMobileRequest.custImag.Title = "My Image"; imageMobileRequest.custImag.FileName = "My Image"; imageMobileRequest.custImag.Description = "My ImageMy ImageMy Image"; imageMobileResponse = registerController.addCustomerImage(imageMobileRequest, _token); } Navigation.PushAsync(new MyProfile()); }
public UploadCustomerImageMobileResponse addCustomerImage(UploadCustomerImageMobileRequest imageMobileRequest, string token) { UploadCustomerImageMobileResponse resp = null; try { using (HttpClient client = new HttpClient()) { client.BaseAddress = new Uri(ConstantData.ApiURL.ToString() + "CustomerMobile/UploadImage"); client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token); var myContent = JsonConvert.SerializeObject(imageMobileRequest); var buffer = System.Text.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; resp = JsonConvert.DeserializeObject <UploadCustomerImageMobileResponse>(responseStream); } else { ApiMessage mes = new ApiMessage(); mes.ErrorCode = response.StatusCode.ToString(); mes.ErrorMessage = response.ReasonPhrase.ToString(); mes.Status = response.IsSuccessStatusCode.ToString(); resp.message = mes; } } } catch (Exception ex) { throw ex; } return(resp); }
private async void DoneBtn_Clicked(object sender, EventArgs e) { if (string.IsNullOrEmpty(licenceNumber.Text)) { await PopupNavigation.Instance.PushAsync(new Error_popup("Please enter your drivers license number.")); } else if (!licExpireDateSelected) { await PopupNavigation.Instance.PushAsync(new Error_popup("Please enter your drivers license expiration date.")); } else if (licenceExpiryDate.Date <= DateTime.Now) { await PopupNavigation.Instance.PushAsync(new Error_popup("Your license has expired")); } else { bool busy = false; if (!busy) { try { busy = true; await PopupNavigation.Instance.PushAsync(new LoadingPopup("Saving your Information")); await Task.Run(() => { customer.LicenseNumber = licenceNumber.Text; customer.LicenseExpiryDate = licenceExpiryDate.Date; if (!licIssueDateSelected) { customer.LicenseIssueDate = null; } else if (licIssueDateSelected) { customer.LicenseIssueDate = licenceIssueDate.Date; } if (licenceStatePicker.SelectedIndex != -1) { customer.LicenseIssueState = licenceStatePicker.SelectedItem.ToString(); } if (images != null) { imageMobileRequest.custImag = images; } RegisterController registerController = new RegisterController(); customerID = registerController.registerUser(customer, _token); if (images != null && customerID > 0) { imageMobileRequest.custImag.CustomerID = customerID; imageMobileRequest.custImag.ImageID = customerID; imageMobileRequest.custImag.Title = "My Image"; imageMobileRequest.custImag.FileName = "My Image"; imageMobileRequest.custImag.Description = "My ImageMy ImageMy Image"; imageMobileResponse = registerController.addCustomerImage(imageMobileRequest, _token); } if (customerID > 0) { if (licfrontIamgeStat.Base64 != null || licBackIamgeStat.Base64 != null) { if (licfrontIamgeStat.Base64 != null) { LicenceImage licenceImage = new LicenceImage(); licenceImage.base64DocumentContent = licfrontIamgeStat.Base64; licenceImage.refType = (short)ReferenceType.Customer; licenceImage.refId = customerID; LicenceImagesRequest.FrontImage = licenceImage; } if (licBackIamgeStat.Base64 != null) { LicenceImage licenceImage = new LicenceImage(); licenceImage.base64DocumentContent = licBackIamgeStat.Base64; licenceImage.refType = (short)ReferenceType.Customer; licenceImage.refId = customerID; LicenceImagesRequest.BackImage = licenceImage; } licenceImageResponse = registerController.addLicenceImage(LicenceImagesRequest, _token); } } }); } finally { busy = false; await PopupNavigation.Instance.PopAllAsync(); } } if (customerID > 0) { Constants.IsRegisteredandNotLogin = true; await PopupNavigation.Instance.PushAsync(new SavedSuccessfullyPopup()); } else { await PopupNavigation.Instance.PushAsync(new Error_popup("Registration failed.Please try again")); } } }
private async void SaveBtn_Clicked(object sender, EventArgs e) { CustomerImages customerImages = new CustomerImages(); RegisterController registerController = new RegisterController(); images.UploadedDate = UploadedDate; images.Base64 = _base64Image; images.PhysicalPath = PhysicalPath; if (images != null && customerID > 0) { imageMobileRequest.custImag = images; imageMobileRequest.custImag.CustomerID = customerID; imageMobileRequest.custImag.ImageID = customerID; imageMobileRequest.custImag.Title = "My Image"; imageMobileRequest.custImag.FileName = "My Image"; imageMobileRequest.custImag.Description = "My ImageMy ImageMy Image"; bool busy = false; if (!busy) { try { busy = true; await PopupNavigation.Instance.PushAsync(new LoadingPopup("Loading details...")); await Task.Run(() => { try { imageMobileResponse = registerController.addCustomerImage(imageMobileRequest, _token); } catch (Exception ex) { PopupNavigation.Instance.PushAsync(new ErrorWithClosePagePopup(ex.Message)); } finally { if (imageMobileResponse != null) { if (imageMobileResponse.message != null) { if (imageMobileResponse.message.ErrorCode == "200") { if (Constants.customerDetails.CustomerImages == null) { Constants.customerDetails.CustomerImages = new List <CustomerImages>(); } Constants.customerDetails.CustomerImages.Add(new CustomerImages() { Base64 = _base64Image }); } } } } }); } finally { await PopupNavigation.Instance.PopAsync(); busy = false; } } } await Navigation.PopModalAsync(); }