Exemple #1
0
        public UpdateCustomerProfileDetailsMobileResponse updateUser(UpdateCustomerProfileDetailsMobileRequest profileDetailsMobileRequest, string token)
        {
            UpdateCustomerProfileDetailsMobileResponse response = null;

            try
            {
                response = registerservice.updateUser(profileDetailsMobileRequest, token);
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return(response);
        }
Exemple #2
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);
        }
Exemple #3
0
        public UpdateCustomerProfileDetailsMobileResponse updateUser(UpdateCustomerProfileDetailsMobileRequest profileDetailsMobileRequest, string token)
        {
            UpdateCustomerProfileDetailsMobileResponse resp = null;

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

                    var myContent   = JsonConvert.SerializeObject(profileDetailsMobileRequest);
                    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 <UpdateCustomerProfileDetailsMobileResponse>(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);
        }
Exemple #4
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."));
                    }
                }
            }
        }
Exemple #5
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));
                            }
                        }
                    }
                }
            }
        }