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); } } }
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); }
public override void WriteViews() { viewsHelper.WriteBoundViews(Customer); }
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); }