public List <CustomerSeachResult> getCustomerByFilter(CustomerSerach customerSerach, string token)
        {
            List <CustomerSeachResult> result = null;

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

                    var myContent   = JsonConvert.SerializeObject(customerSerach);
                    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;
                        result = JsonConvert.DeserializeObject <List <CustomerSeachResult> >(responseStream);
                    }
                }
            }

            catch (Exception ex)
            {
                throw ex;
            }
            return(result);
        }
        public AddNewDriver(ReservationView reservationView, CustomerSerach filter)
        {
            InitializeComponent();


            //want to edit
            selectedVehicle = null;



            customer             = new CustomerReview();
            this.filter          = filter;
            customerID           = 0;
            this.reservationView = reservationView;
            _token = App.Current.Properties["currentToken"].ToString();

            DateOfBithEntry.MaximumDate = DateTime.Now.AddYears(-18);
            countryResponse             = getAllCountry(_token);
            List <string> countryList = new List <string>();

            if (countryResponse.countryList.Count > 0)
            {
                foreach (Country k in countryResponse.countryList)
                {
                    countryList.Add(k.CountryName);
                }
                ;
            }
            countryPicker.ItemsSource = countryList;

            countryPicker.SelectedItem = "USA";
            List <string> stateList = new List <string>();
            int?          counid    = null;

            foreach (Country c in countryResponse.countryList)
            {
                if (c.CountryName == countryPicker.SelectedItem.ToString())
                {
                    counid = c.CountryId;
                }
            }
            ;

            if (counid != null)
            {
                GetAllStateForMobileRequest stateRequest = new GetAllStateForMobileRequest();
                stateRequest.CountryID = counid.Value;
                stateResponse          = getStates(stateRequest, _token);
                if (stateResponse.stateList.Count > 0)
                {
                    foreach (State s in stateResponse.stateList)
                    {
                        stateList.Add(s.StateName);
                    }
                    ;
                }
                statePicker.ItemsSource = stateList;
            }
        }
        public RegisterPage()
        {
            InitializeComponent();

            customer             = new CustomerReview();
            customerSerach       = new CustomerSerach();
            customerSeachResults = null;
            //var assembly = typeof(LoginPage);
            //regiseterNxtBtn.ImageSource = ImageSource.FromResource("BespokeMobile.Assets.nextIcon.png", assembly);
            //registerPageImage.Source= ImageSource.FromResource("BespokeMobile.Assets.registerPageImage.png", assembly);
        }
        public RegisterPage(int fromVal)
        {
            InitializeComponent();

            customer             = new CustomerReview();
            customerSerach       = new CustomerSerach();
            customerSeachResults = null;
            //var assembly = typeof(LoginPage);
            //regiseterNxtBtn.ImageSource = ImageSource.FromResource("MaxVonGrafKftMobile.Assets.nextIcon.png", assembly);
            //registerPageImage.Source= ImageSource.FromResource("MaxVonGrafKftMobile.Assets.registerPageImage.png", assembly);
            this.fromVal = fromVal;
        }
        public List <CustomerSeachResult> getCustomerByFilter(CustomerSerach customerSerach, string token)
        {
            List <CustomerSeachResult> response;

            try
            {
                response = customerService.getCustomerByFilter(customerSerach, token);
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return(response);
        }
        public AddPersonalInformationPage(CustomerReview customer)
        {
            InitializeComponent();
            //var assembly = typeof(LoginPage);
            //NxtBtn.ImageSource = ImageSource.FromResource("NativeCamperVans.Assets.nextIcon.png", assembly);
            //BacKBtn.ImageSource = ImageSource.FromResource("NativeCamperVans.Assets.backicon.png", assembly);
            //PhotoBtn.ImageSource = ImageSource.FromResource("NativeCamperVans.Assets.cameraIcon.png", assembly);

            FirstNameEntry.Keyboard = Keyboard.Create(KeyboardFlags.CapitalizeSentence);



            this.customer        = customer;
            images               = new CustomerImages();
            customerSerach       = new CustomerSerach();
            customerSeachResults = null;

            _token = App.Current.Properties["currentToken"].ToString();

            countryResponse = getAllCountry(_token);
            List <string> countryList = new List <string>();

            if (countryResponse.countryList.Count > 0)
            {
                foreach (Country k in countryResponse.countryList)
                {
                    countryList.Add(k.CountryName);
                }
                ;
            }
            countryPicker.ItemsSource   = countryList;
            DateOfBithEntry.MaximumDate = DateTime.Now.AddYears(-21);


            if (Constants.admin != null)
            {
                if (Constants.admin.CountryId > 0)
                {
                    if (Constants.countriesHasState.Contains(Constants.admin.CountryId))
                    {
                        statePicker.Title           = "State";
                        PostalCodeEntry.Placeholder = "Zip code";
                    }
                    ;

                    string cliCountry = returnCountryNameByID(Constants.admin.CountryId);
                    if (cliCountry != null)
                    {
                        countryPicker.SelectedItem = cliCountry;
                    }
                }
            }
            else
            {
                countryPicker.SelectedItem = "USA";
            }



            List <string> stateList = new List <string>();
            int?          counid    = null;

            foreach (Country c in countryResponse.countryList)
            {
                if (c.CountryName == countryPicker.SelectedItem.ToString())
                {
                    counid = c.CountryId;
                }
            }
            ;

            if (counid != null)
            {
                GetAllStateForMobileRequest stateRequest = new GetAllStateForMobileRequest();
                stateRequest.CountryID = counid.Value;
                stateResponse          = getStates(stateRequest, _token);
                if (stateResponse.stateList.Count > 0)
                {
                    foreach (State s in stateResponse.stateList)
                    {
                        stateList.Add(s.StateName);
                    }
                    ;
                }
                statePicker.ItemsSource = stateList;
                if (countryPicker.SelectedItem.ToString() == "USA")
                {
                    statePicker.SelectedItem = "GEORGIA";
                }
            }
        }
Beispiel #7
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 (!new EmailAddressAttribute().IsValid(emailEntry.Text) || string.IsNullOrEmpty(emailEntry.Text))
            {
                await PopupNavigation.Instance.PushAsync(new Error_popup("Please enter a valid email address"));
            }
            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.Replace(" ", "").Replace("(", "").Replace(")", "").Replace("-", "");
                customerReview.ClientId          = Constants.ClientId;
                customerReview.LicenseNumber     = licenceNumber.Text;
                customerReview.LicenseExpiryDate = licenceexpiDate.Date;
                customerReview.LicenseIssueDate  = licIssueDate.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 (LicStatePicker.SelectedIndex != -1)
                {
                    customerReview.LicenseIssueState = LicStatePicker.SelectedItem.ToString();
                }
                //else
                //{
                //    customerReview.LicenseIssueState = null;
                //}

                bool isExisting = false;

                if (oldEmail.ToLower() != emailEntry.Text.Replace(" ", "").ToLower())
                {
                    CustomerSerach customerSerach = new CustomerSerach();
                    customerSerach.Email  = emailEntry.Text;
                    customerSerach.Active = true;
                    List <CustomerSeachResult> customerSeachResults = null;

                    customerSeachResults = customoerController.getCustomerByFilter(customerSerach, _token);

                    if (customerSeachResults != null)
                    {
                        if (customerSeachResults.Count > 0)
                        {
                            foreach (CustomerSeachResult csr in customerSeachResults)
                            {
                                if (csr.Email.ToLower() == emailEntry.Text.ToLower())
                                {
                                    isExisting = true;
                                }
                            }
                        }
                    }
                }
                customerReview.Email = emailEntry.Text;
                ProfileDetailsMobileRequest.custReview = customerReview;


                bool busy = false;
                if (!busy)
                {
                    if (!isExisting)
                    {
                        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!", 3));
                                }
                            }
                        }
                    }
                    else
                    {
                        await PopupNavigation.Instance.PushAsync(new Error_popup("Email address already exists.Please try a different email address."));
                    }
                }
            }
        }