Пример #1
0
        public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
        {
            base.OnCreateView(inflater, container, savedInstanceState);
            this.FragmentView = inflater.Inflate(Resource.Layout.layout_registration_customer_photo, container, false);

            if (savedInstanceState != null && _inWizard)
            {
                string regInfo = savedInstanceState.GetString(BundledRegistrationInfo);
                if (!regInfo.IsBlank())
                {
                    _personRegistrationInfo = JsonConvert.DeserializeObject <SalesApp.Core.BL.Models.People.Customer>(regInfo);
                }
            }

            // App trackking
            GoogleAnalyticService.Instance.TrackScreen("Customer Photo");

            _addCustomerPhoto      = this.FragmentView.FindViewById <ImageView>(Resource.Id.imageView_add_customer_photo);
            _addDocumentPhoto      = this.FragmentView.FindViewById <ImageView>(Resource.Id.imageView_add_document_photo);
            _customerPhotoTextView = this.FragmentView.FindViewById <TextView>(Resource.Id.textView_customer_photo);
            _documentPhotoTextView = this.FragmentView.FindViewById <TextView>(Resource.Id.textView_document_photo);
            _titleTextView         = this.FragmentView.FindViewById <TextView>(Resource.Id.textView_select_product);
            _listView            = this.FragmentView.FindViewById <ListView>(Resource.Id.listView_photos);
            _customerPhotoLayout = this.FragmentView.FindViewById <LinearLayout>(Resource.Id.customer_photo_layout);
            _selectProductLayout = this.FragmentView.FindViewById <RelativeLayout>(Resource.Id.select_product_layout);
            View buttonDivider = this.FragmentView.FindViewById(Resource.Id.bottom_separator);

            _photoListAdapter = new PhotoListAdapter(_inWizard, Photos, _activity, this);
            _listView.Adapter = _photoListAdapter;

            if (_inWizard)
            {
                WizardActivity.ButtonNext.Text       = GetString(Resource.String.next);
                WizardActivity.ButtonNext.Visibility = ViewStates.Visible;
                buttonDivider.Visibility             = ViewStates.Gone;
            }
            else
            {
                Activity.SetTitle(Resource.String.customer_photo_title);
                _selectProductLayout.Visibility = ViewStates.Gone;
                _customerPhotoTextView.Text     = GetString(Resource.String.add_customer_photo);
                _documentPhotoTextView.Text     = GetString(Resource.String.add_document_photo);
                buttonDivider.Visibility        = ViewStates.Visible;
            }

            RefreshList();
            _addCustomerPhoto.Click += delegate
            {
                _personRegistrationInfo.TypeOfPhotoBeingTaken = PhotoType.Customer;
                TakePhoto();
            };

            _addDocumentPhoto.Click += delegate
            {
                _personRegistrationInfo.TypeOfPhotoBeingTaken = PhotoType.Document;
                TakePhoto();
            };

            return(this.FragmentView);
        }
Пример #2
0
        protected void WriteProspectIfConversion()
        {
            if (WizardActivity.BundledItems == null || !WizardActivity.BundledItems.ContainsKey(KeyProspectIdBundled))
            {
                return;
            }

            string prospectJson = WizardActivity.BundledItems[KeyProspectIdBundled].ToString();

            this._prospectBeingConverted = JsonConvert.DeserializeObject <ProspectSearchResult>(prospectJson);
            if (this._prospectBeingConverted == null)
            {
                return;
            }

            SalesApp.Core.BL.Models.People.Customer c = new SalesApp.Core.BL.Models.People.Customer
            {
                FirstName = this._prospectBeingConverted.FirstName,
                LastName  = this._prospectBeingConverted.LastName,
                Phone     = this._prospectBeingConverted.Phone,
                DsrPhone  = this._prospectBeingConverted.DsrPhone
            };

            FillFromExistingRecord(c);

            WizardActivity.IsProspectConversion = true;
            View.FindViewById <EditText>(Resource.Id.edtPhone).Enabled = false;

            /*
             *  Fixes issue 18879 - Missing Customer ID number
             */
            WizardActivity.BundledItems.Remove(KeyProspectIdBundled);
        }
Пример #3
0
        public override string GetData()
        {
            viewsHelper.Read();
            if (Customer == null)
            {
                return("");
            }

            Customer = viewsHelper.Read();
            return(JsonConvert.SerializeObject(Customer));
        }
Пример #4
0
        public override void SetData(string serializedString)
        {
            if (serializedString.IsBlank() == false)
            {
                Customer = JsonConvert.DeserializeObject <SalesApp.Core.BL.Models.People.Customer>(serializedString);

                if (viewsHelper != null)
                {
                    viewsHelper.WriteBoundViews(Customer);
                }
            }
        }
Пример #5
0
 public override void SetData(string serializedString)
 {
     if (!serializedString.IsBlank())
     {
         _personRegistrationInfo =
             JsonConvert.DeserializeObject <SalesApp.Core.BL.Models.People.Customer>(serializedString);
         if (_personRegistrationInfo.Product == null)
         {
             _personRegistrationInfo.Product = new Product();
         }
     }
 }
Пример #6
0
        public override void CreateView()
        {
            viewsHelper = new ViewsHelper <SalesApp.Core.BL.Models.People.Customer>(this.Activity as ActivityBase, this.View);
            if (Customer == null)
            {
                Customer = new SalesApp.Core.BL.Models.People.Customer();

                Customer.Product = new Product();
            }

            // App trackking
            GoogleAnalyticService.Instance.TrackScreen("Customer basic info");
        }
Пример #7
0
 public override void OnCreate(Bundle savedInstanceState)
 {
     base.OnCreate(savedInstanceState);
     if (savedInstanceState != null)
     {
         string regInfo = savedInstanceState.GetString(BundledRegistrationInfo);
         if (!regInfo.IsBlank())
         {
             this.personRegistrationInfo =
                 JsonConvert.DeserializeObject <SalesApp.Core.BL.Models.People.Customer>(regInfo);
         }
     }
 }
Пример #8
0
        public async Task <bool> ShowOverlayIfOffline(SalesApp.Core.BL.Models.People.Customer customer)
        {
            this._fragmentInfo = new FragmentInfo();
            this._fragmentInfo.SetArgument(FragmentInfo.ResourceIdBundleKey, Resource.Layout.fragment_choose_registration_type);

            this._fragmentInfo.ViewCreated += (sender, args) =>
            {
                ViewsHelper <Person> viewsHelper = new ViewsHelper <Person>(Activity as ActivityBase,
                                                                            _fragmentInfo.InflatedView);

                viewsHelper.BindEvent
                (
                    BindableEvents.OnClick
                    , Resource.Id.linFirstTimeProduct
                    , linFirstTimeProduct =>
                {
                    WizardActivity.HideOverlay(false);
                    IsAdditionalProduct              = false;
                    customer.IsAdditionalProduct     = IsAdditionalProduct;
                    WizardActivity.ButtonNextEnabled = true;

                    string serializedData = JsonConvert.SerializeObject(customer);
                    WizardActivity.CurrentFragment.SetData(serializedData);
                    WizardActivity.Go(true);
                });

                viewsHelper.BindEvent(
                    BindableEvents.OnClick,
                    Resource.Id.linAddProduct,
                    linAddProduct =>
                {
                    WizardActivity.HideOverlay(false);
                    IsAdditionalProduct              = true;
                    customer.IsAdditionalProduct     = IsAdditionalProduct;
                    WizardActivity.ButtonNextEnabled = true;

                    string serializedData = JsonConvert.SerializeObject(customer);
                    WizardActivity.CurrentFragment.SetData(serializedData);
                    WizardActivity.Go(true);
                });

                viewsHelper.Write(Resource.Id.tvPersonName, customer.FullName);
                viewsHelper.Write(Resource.Id.tvPhone, customer.Phone);
                viewsHelper.WriteBoundViews(customer);
            };

            WizardActivity.ShowOverlay(_fragmentInfo, false);
            return(false);
        }
Пример #9
0
        public override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            this._startPointIntent = ActivityBase.StartPointIntent;
            string nationalId = string.Empty;
            string phone      = string.Empty;

            if (this.Arguments != null)
            {
                this._inWizard = this.Arguments.GetBoolean(InWizardActivity, true);
                nationalId     = this.Arguments.GetString(NationalIdKey);
                phone          = this.Arguments.GetString(PhoneKey);
            }

            if (savedInstanceState != null)
            {
                _personRegistrationInfo =
                    savedInstanceState.GetJsonObject <SalesApp.Core.BL.Models.People.Customer>(BundledRegistrationInfo);

                if (_inWizard)
                {
                    _registrationSuccessfulFragment =
                        Activity.SupportFragmentManager.GetFragment(savedInstanceState, RegistrationSuccessfulFragment)
                        as WizardOverlayFragment;
                    _registrationFailedFragment =
                        Activity.SupportFragmentManager.GetFragment(savedInstanceState, RegistrationFailedFragment) as
                        WizardOverlayFragment;
                    //startPointIntent = savedInstanceState.GetEnum<IntentStartPointTracker.IntentStartPoint>(StartPointIntentKey);
                }
                else
                {
                    _inWizard = savedInstanceState.GetBoolean(InWizardKey);
                }
            }

            if (!_inWizard)
            {
                if (_personRegistrationInfo == null)
                {
                    _personRegistrationInfo = new SalesApp.Core.BL.Models.People.Customer();
                    this._personRegistrationInfo.NationalId = nationalId;
                    this._personRegistrationInfo.Phone      = phone;
                }
            }

            _photoWidth  = Settings.Instance.CustomerPhotoWidthScale;
            _photoHeight = Settings.Instance.CustomerPhotoHeightScale;
        }
Пример #10
0
        /// <summary>
        /// Creates the view for this fragment
        /// </summary>
        /// <param name="inflater">The inflator</param>
        /// <param name="container">The container</param>
        /// <param name="savedInstanceState">The saved state</param>
        /// <returns>The view</returns>
        public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
        {
            if (savedInstanceState != null)
            {
                string regInfo = savedInstanceState.GetString(BundledRegistrationInfo);
                if (!regInfo.IsBlank())
                {
                    this.personRegistrationInfo =
                        JsonConvert.DeserializeObject <SalesApp.Core.BL.Models.People.Customer>(regInfo);
                }
            }

            // App trackking
            GoogleAnalyticService.Instance.TrackScreen("Product Selection");

            return(base.OnCreateView(inflater, container, savedInstanceState));
        }
        /// <summary>
        /// Called to save a customer to the device
        /// </summary>
        /// <returns>An empty task</returns>
        private async Task SaveCustomerToDevice(CustomerRegistrationCompletedEventArgs e)
        {
            if (e == null)
            {
                return;
            }

            this.personRegistrationInfo.Channel = e.Channel;

            //if we have a successfully generated customer registration Id from the API, set the corresponding property in the Customer Model
            if (e.RegistrationId != Guid.Empty)
            {
                this.personRegistrationInfo.RegistrationId = e.RegistrationId;
            }

            try
            {
                SalesApp.Core.BL.Models.People.Customer customer =
                    await new CustomersController().SaveCustomerToDevice(this.personRegistrationInfo, e, false);

                if (customer == null || customer.Id == default(Guid))
                {
                    new ReusableScreens(this.Activity)
                    .ShowInfo(
                        Resource.String.customer_save_err_actionbar,
                        Resource.String.customer_save_err_title,
                        Resource.String.customer_save_err_message,
                        Resource.String.customer_save_err_button);
                }
            }
            catch (DuplicateValuesException dx)
            {
                new ReusableScreens(this.Activity)
                .ShowInfo(
                    Resource.String.customer_save_err_actionbar,
                    Resource.String.customer_save_err_title,
                    Resource.String.customer_duplicate_error_message,
                    Resource.String.customer_save_err_button);
            }
        }
Пример #12
0
        public override bool Validate()
        {
            Customer = viewsHelper.Read(true);

            bool phoneIsDuplicate = false;

            if (EnableDuplicateChecking)
            {
                phoneIsDuplicate = AsyncHelper.RunSync(async() => await ShowOverlayIfPhoneNumberDuplicate(Customer.Phone, Customer.NationalId));
                _madeCheck       = phoneIsDuplicate;
            }

            if (IsAdditionalProduct)
            {
                Customer.IsAdditionalProduct = true;
            }

            if (phoneIsDuplicate)
            {
                return(false);
            }

            bool valid = Validator.ValidateAll(View);

            if (!valid)
            {
                return(false);
            }

            if (!_madeCheck && !Resolver.Instance.Get <IConnectivityService>().HasConnection())
            {
                //since we don't have internet,
                //display a dialog to choose whether this is an additional product since we cannot(have tried locally already)
                return(AsyncHelper.RunSync(async() => await ShowOverlayIfOffline(Customer)));
            }

            return(true);
        }
Пример #13
0
        public async Task <bool> ShowOverlayIfPhoneNumberDuplicate(string phone, string nationalId = null)
        {
            ErrorFilterFlags flag = ErrorFilterFlags.DisableErrorHandling;
            Person           person;

            SalesApp.Core.BL.Models.People.Customer customer = await new CustomersController().GetPersonIfExists(phone, nationalId, filterFlags: flag, checkDuplicate: false);
            SalesApp.Core.BL.Models.People.Prospect prospect = null;

            if (customer == null)
            {
                prospect = await new ProspectsController().GetPersonIfExists(phone, filterFlags: flag, checkDuplicate: false);
                person   = JsonConvert.DeserializeObject <Person>(JsonConvert.SerializeObject(prospect));
            }
            else
            {
                if (customer.PersonType == PersonTypeEnum.Prospect)
                {
                    prospect =
                        JsonConvert.DeserializeObject <SalesApp.Core.BL.Models.People.Prospect>(
                            JsonConvert.SerializeObject(customer));
                }
                else
                {
                    string         urlParam       = customer.Phone + "&foradditionalproduct=true";
                    CustomerStatus customerStatus = await new CustomerStatusApi().GetAsync(urlParam);

                    if (customerStatus != null)
                    {
                        customer.AccountStatus = customerStatus.AccountStatus;
                    }
                }

                person = JsonConvert.DeserializeObject <Person>(JsonConvert.SerializeObject(customer));
            }

            if (person == null)
            {
                return(false);
            }

            this._fragmentInfo = new FragmentInfo();
            this._fragmentInfo.SetArgument(FragmentInfo.ResourceIdBundleKey, Resource.Layout.fragment_unified_existing_person);

            this._fragmentInfo.ViewCreated += (sender, args) =>
            {
                ViewsHelper <Person> viewsHelper = new ViewsHelper <Person>(Activity as ActivityBase,
                                                                            _fragmentInfo.InflatedView);

                viewsHelper.BindEvent
                (
                    BindableEvents.OnClick
                    , Resource.Id.linEditCustomer
                    , linEditCustomer =>
                {
                    WizardActivity.HideOverlay(true);
                });

                viewsHelper.BindEvent(
                    BindableEvents.OnClick,
                    Resource.Id.linAddProduct,
                    linAddProduct =>
                {
                    // if doing prospect registration, do conversion to customer
                    if (WizardActivity.WizardType == WizardTypes.ProspectRegistration)
                    {
                        // do conversion to customer
                        if (person.PersonType == PersonTypeEnum.Prospect)
                        {
                            ProspectSearchResult psr = JsonConvert.DeserializeObject <ProspectSearchResult>(JsonConvert.SerializeObject(prospect));
                            Dictionary <string, object> bundledItems = new Dictionary <string, object>();
                            bundledItems.Add(KeyProspectIdBundled, psr);

                            WizardLauncher.Launch(Activity, WizardTypes.CustomerRegistration, WizardActivity.StartPoint, bundledItems);
                        }
                        else
                        {
                            // posible additional product
                            if (customer != null)
                            {
                                WizardActivity.HideOverlay(true);
                                IsAdditionalProduct = true;
                                WizardActivity.IsProspectConversion      = true;
                                CustomerSearchResult csr                 = JsonConvert.DeserializeObject <CustomerSearchResult>(JsonConvert.SerializeObject(customer));
                                Dictionary <string, object> bundledItems = new Dictionary <string, object>();
                                bundledItems.Add(KeyCustomerIdBundled, csr);

                                WizardLauncher.Launch(Activity, WizardTypes.CustomerRegistration, WizardActivity.StartPoint, bundledItems);
                            }
                        }
                    }
                    else
                    {
                        // customer registration
                        if (person.PersonType == PersonTypeEnum.Prospect)
                        {
                            // auto fill the details
                            FillFromExistingRecord(prospect);
                            WizardActivity.IsProspectConversion = true;
                        }
                        else
                        {
                            // auto fill the details
                            FillFromExistingRecord(customer);
                        }

                        WizardActivity.HideOverlay(true);
                        IsAdditionalProduct = true; // though this may be cheating ;)
                        WizardActivity.GoNext();
                    }
                });

                viewsHelper.Write(Resource.Id.tvPersonName, person.FullName);
                viewsHelper.Write(Resource.Id.tvPhone, person.Phone);
                viewsHelper.WriteBoundViews(customer);

                if (customer != null && customer.AccountStatus != null && !customer.AccountStatus.Equals("Active"))
                {
                    ShowConversionButton(_fragmentInfo.InflatedView, ViewStates.Gone);
                    ShowPersonStatus(_fragmentInfo.InflatedView);
                }

                if (person.PersonType == PersonTypeEnum.Prospect)
                {
                    // show conversion button
                    ShowConversionButton(_fragmentInfo.InflatedView, ViewStates.Visible);
                }
            };

            WizardActivity.ShowOverlay(_fragmentInfo, false);
            return(true);
        }
Пример #14
0
 public override void SetData(string serializedString)
 {
     this._customer = JsonConvert.DeserializeObject <SalesApp.Core.BL.Models.People.Customer>(serializedString);
 }