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;
        }
Example #2
0
        public AddLicenceImageResponse addLicenceImage(AddLicenceImagesRequest licenceImagesRequest, string token)
        {
            AddLicenceImageResponse resp = null;

            try
            {
                using (HttpClient client = new HttpClient())
                {
                    client.BaseAddress = new Uri(ConstantData.ApiURL.ToString() + "CustomerMobile/UploadLicenceImages");
                    client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
                    client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token);

                    var myContent   = JsonConvert.SerializeObject(licenceImagesRequest);
                    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 <AddLicenceImageResponse>(responseStream);
                    }
                }
            }

            catch (Exception ex)
            {
                throw ex;
            }
            return(resp);
        }
Example #3
0
        public AddLicenceImageResponse addLicenceImage(AddLicenceImagesRequest licenceImagesRequest, string token)
        {
            AddLicenceImageResponse response = null;

            try
            {
                response = registerservice.addLicenceImage(licenceImagesRequest, token);
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return(response);
        }
Example #4
0
        public UpdateProfile(CustomerReview customerReview)
        {
            InitializeComponent();
            DateOfBithEntry.MaximumDate = DateTime.Now.AddYears(-18);
            //licIssueDate.MaximumDate = DateTime.Now;
            licenceexpiDate.MinimumDate = DateTime.Now;
            this.customerReview         = customerReview;
            _token                                = App.Current.Properties["currentToken"].ToString();
            customerId                            = (int)Application.Current.Properties["CustomerId"];
            countryResponse                       = null;
            stateResponse                         = null;
            ProfileDetailsMobileRequest           = new UpdateCustomerProfileDetailsMobileRequest();
            profileDetailsMobileResponse          = null;
            portalDetailsMobileRequest            = new GetCustomerPortalDetailsMobileRequest();
            portalDetailsMobileRequest.customerId = customerId;
            PortalDetailsMobileResponse           = null;
            customoerController                   = new CustomerController();
            Images                                = null;
            //licenceIssueDate.MaximumDate = DateTime.Now;
            //licenceExpiryDate.MinimumDate = DateTime.Now;
            licExpireDateSelected = false;
            licIssueDateSelected  = false;
            licfrontIamgeStat     = new CustomerImages();
            licBackIamgeStat      = new CustomerImages();
            LicenceImagesRequest  = new AddLicenceImagesRequest();
            licenceImageResponse  = null;

            var editPhoto = new TapGestureRecognizer();

            editPhoto.Tapped += (s, e) =>
            {
                if (Images != null)
                {
                    if (Images.Base64 == null)
                    {
                        PopupNavigation.PushAsync(new editPrrofilePhotoPage());
                    }
                    else
                    {
                        PopupNavigation.PushAsync(new editPrrofilePhotoPage(Images));
                    }
                }
                else
                {
                    PopupNavigation.PushAsync(new editPrrofilePhotoPage());
                }
            };
            profileImage.GestureRecognizers.Add(editPhoto);
        }
        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"));
                }
            }
        }
Example #6
0
        private async void UpdateBtn_Clicked(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(FirstNameEntry.Text))
            {
                await PopupNavigation.Instance.PushAsync(new Error_popup("Please enter a first name."));
            }
            else if (string.IsNullOrEmpty(LastNameEntry.Text))
            {
                await PopupNavigation.Instance.PushAsync(new Error_popup("Please enter a last name."));
            }
            else if (string.IsNullOrEmpty(AddressEntry.Text))
            {
                await PopupNavigation.Instance.PushAsync(new Error_popup("Please enter your address."));
            }
            else if (DateOfBithEntry.Date.AddYears(18).AddDays(1) > DateTime.Now || DateOfBithEntry.Date == null)
            {
                await PopupNavigation.Instance.PushAsync(new Error_popup("You must be at least 21 years old to reserve a vehicle"));
            }
            else if (string.IsNullOrEmpty(CityEntry.Text))
            {
                await PopupNavigation.Instance.PushAsync(new Error_popup("Please enter your city."));
            }
            else if (countryPicker.SelectedIndex == -1)
            {
                await PopupNavigation.Instance.PushAsync(new Error_popup("Please select your country"));
            }
            else if (statePicker.SelectedIndex == -1)
            {
                await PopupNavigation.Instance.PushAsync(new Error_popup("Please select your state"));
            }
            else if (string.IsNullOrEmpty(PostalCodeEntry.Text))
            {
                await PopupNavigation.Instance.PushAsync(new Error_popup("Please enter your zip code"));
            }
            else if (string.IsNullOrEmpty(ContactNoEntry.Text))
            {
                await PopupNavigation.Instance.PushAsync(new Error_popup("Please enter a valid contact number"));
            }

            else 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
            {
                customerReview.FirstName         = FirstNameEntry.Text;
                customerReview.LastName          = LastNameEntry.Text;
                customerReview.Address1          = AddressEntry.Text;
                customerReview.City              = CityEntry.Text;
                customerReview.CountryId         = returnCountryIdByCountryName(countryPicker.SelectedItem.ToString());
                customerReview.CountryName       = countryPicker.SelectedItem.ToString();
                customerReview.StateId           = returnStateIdByStateName(statePicker.SelectedItem.ToString());
                customerReview.StateName         = statePicker.SelectedItem.ToString();
                customerReview.ZipCode           = PostalCodeEntry.Text;
                customerReview.hPhone            = ContactNoEntry.Text;
                customerReview.ClientId          = Constants.ClientId;
                customerReview.LicenseNumber     = licenceNumber.Text;
                customerReview.LicenseExpiryDate = licenceExpiryDate.Date;
                customerReview.DateOfbirth       = DateOfBithEntry.Date;

                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;
                    }
                }



                if (!licIssueDateSelected)
                {
                    customerReview.LicenseIssueDate = null;
                }
                else if (licIssueDateSelected)
                {
                    customerReview.LicenseIssueDate = licenceIssueDate.Date;
                }

                if (licenceStatePicker.SelectedIndex != -1)
                {
                    customerReview.LicenseIssueState = licenceStatePicker.SelectedItem.ToString();
                }
                else
                {
                    customerReview.LicenseIssueState = null;
                }

                ProfileDetailsMobileRequest.custReview = customerReview;


                bool busy = false;
                if (!busy)
                {
                    try
                    {
                        busy = true;
                        await PopupNavigation.Instance.PushAsync(new LoadingPopup("Updating your informations"));

                        await Task.Run(() =>
                        {
                            RegisterController registerController = new RegisterController();

                            try
                            {
                                profileDetailsMobileResponse = registerController.updateUser(ProfileDetailsMobileRequest, _token);
                                if (licfrontIamgeStat.Base64 != null || licBackIamgeStat.Base64 != null)
                                {
                                    licenceImageResponse = registerController.addLicenceImage(LicenceImagesRequest, _token);
                                }
                            }
                            catch (Exception ex)
                            {
                                PopupNavigation.Instance.PushAsync(new ErrorWithClosePagePopup(ex.Message));
                            }
                        });
                    }

                    finally
                    {
                        busy = false;
                        if (PopupNavigation.Instance.PopupStack.Count == 1)
                        {
                            await PopupNavigation.Instance.PopAsync();
                        }
                        if (PopupNavigation.Instance.PopupStack.Count > 1)
                        {
                            if (PopupNavigation.Instance.PopupStack[PopupNavigation.Instance.PopupStack.Count - 1].GetType() != typeof(ErrorWithClosePagePopup) && PopupNavigation.Instance.PopupStack[PopupNavigation.Instance.PopupStack.Count - 1].GetType() != typeof(SuccessWithClosePopup))
                            {
                                await PopupNavigation.Instance.PopAllAsync();
                            }
                        }
                        if (profileDetailsMobileResponse != null)
                        {
                            if (profileDetailsMobileResponse.message.ErrorCode == "200")
                            {
                                await PopupNavigation.Instance.PushAsync(new SuccessPopUp("Profile updated successfully!", 2));
                            }
                        }
                    }
                }
            }
        }