Example #1
0
 public override void CreateView()
 {
     viewsHelper = new ViewsHelper <SalesApp.Core.BL.Models.People.Prospect>(Activity as ActivityBase, View);
     if (Prospect == null)
     {
         Prospect = new SalesApp.Core.BL.Models.People.Prospect();
     }
 }
Example #2
0
        public override void SetData(string serializedString)
        {
            _personRegistrationInformation =
                JsonConvert.DeserializeObject <SalesApp.Core.BL.Models.People.Prospect>(
                    serializedString);

            this.ProspectId = _personRegistrationInformation.Id;
        }
Example #3
0
        public override string GetData()
        {
            Prospect = viewsHelper.Read();
            if (Prospect == null)
            {
                return(string.Empty);
            }

            // Prospect = viewsHelper.Read();
            return(JsonConvert.SerializeObject(Prospect));
        }
Example #4
0
        public override void SetData(string serializedString)
        {
            if (serializedString.IsBlank() == false)
            {
                Prospect = JsonConvert.DeserializeObject <SalesApp.Core.BL.Models.People.Prospect>(serializedString);

                if (viewsHelper != null)
                {
                    viewsHelper.WriteBoundViews(Prospect);
                }
            }
        }
Example #5
0
        /// <summary>
        /// Load the registration data from a JSON string
        /// </summary>
        /// <param name="serializedString">The JSON string</param>
        public override void SetData(string serializedString)
        {
            if (!serializedString.IsBlank())
            {
                this.personRegistrationInfo = JsonConvert.DeserializeObject <SalesApp.Core.BL.Models.People.Prospect>(serializedString);

                if (this.personRegistrationInfo.Product == null)
                {
                    this.personRegistrationInfo.Product = new Product();
                }
            }
        }
        /// <summary>
        /// Gets the score as a string
        /// </summary>
        /// <param name="prospect">The prospect</param>
        /// <returns>The the prospect's score as a string</returns>
        private string GetScore(SalesApp.Core.BL.Models.People.Prospect prospect)
        {
            var score = prospect.Score;

            switch (score)
            {
            case 3:
                return(this.Activity.GetString(Resource.String.unified_hot));

            case 2:
                return(this.Activity.GetString(Resource.String.unified_warm));

            default:
                return(this.Activity.GetString(Resource.String.unified_cold));
            }
        }
Example #7
0
        public override bool Validate()
        {
            this.Prospect = this.viewsHelper.Read(true);

            bool phoneIsDuplicate = false;

            if (this.EnableDuplicateChecking)
            {
                phoneIsDuplicate = Task.Run(async() => await ShowOverlayIfPhoneNumberDuplicate(Prospect.Phone)).Result;
            }

            if (phoneIsDuplicate)
            {
                return(false);
            }
            bool validationResult = false;

            validationResult = Validator.ValidateAll(View, true);

            return(validationResult);
        }
Example #8
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);
        }
 public override void SetData(string serializedString)
 {
     this._prospect = JsonConvert.DeserializeObject <SalesApp.Core.BL.Models.People.Prospect>(serializedString);
 }