Пример #1
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);
        }
Пример #2
0
        public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
        {
            base.OnCreateView(inflater, container, savedInstanceState);
            this.View = inflater.Inflate(Resource.Layout.fragment_unified_basic_info, container, false);

            this.CreateView();

            if (savedInstanceState != null)
            {
                this._fragmentInfo = this.Activity.SupportFragmentManager.GetFragment(savedInstanceState, OverLayFragmentBundleKey) as FragmentInfo;

                if (this._fragmentInfo != null)
                {
                    this.WizardActivity.ShowOverlay(this._fragmentInfo, false);
                }

                if (savedInstanceState.ContainsKey(ProspectBeingConvertedBundleKey))
                {
                    this._prospectBeingConverted =
                        JsonConvert.DeserializeObject <ProspectSearchResult>(
                            savedInstanceState.GetString(ProspectBeingConvertedBundleKey));
                }
            }

            return(this.View);
        }
Пример #3
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);
        }
Пример #4
0
 public ProspectItem(ProspectSearchResult searchResult)
 {
     this.SearchResult = searchResult;
 }