private void OpenDualCoinWalletPopup() { var coinVm = Vm.CoinVm.CoinKernel.CoinKernelProfile.SelectedDualCoin; if (coinVm == null || coinVm.CoinProfile == null) { return; } var popup = PopupDualCoinWallet; popup.IsOpen = true; var selected = coinVm.CoinProfile.SelectedDualCoinWallet; bool isDualCoin = true; WalletSelectViewModel vm = null; // 如果服务器上下文刷新了则视图模型一定不等,因为上下文刷新后服务器视图模型会清空重建 bool newVm = popup.Child == null || ((WalletSelectViewModel)((WalletSelect)popup.Child).DataContext).Coin != coinVm; if (newVm) { vm = new WalletSelectViewModel(coinVm, isDualCoin, selected, onOk: selectedResult => { if (selectedResult != null) { if (coinVm.CoinProfile.SelectedDualCoinWallet != selectedResult) { coinVm.CoinProfile.SelectedDualCoinWallet = selectedResult; } else { coinVm.CoinProfile.OnPropertyChanged(nameof(coinVm.CoinProfile.SelectedDualCoinWallet)); selectedResult.OnPropertyChanged(nameof(selectedResult.Name)); selectedResult.OnPropertyChanged(nameof(selectedResult.Address)); } popup.IsOpen = false; } }) { HideView = new DelegateCommand(() => { popup.IsOpen = false; }) }; } if (popup.Child == null) { popup.Child = new WalletSelect(vm); } else if (newVm) { ((WalletSelect)popup.Child).DataContext = vm; } }
public ActionResult SelectWallet(WalletSelectViewModel model) { if (!ModelState.IsValid) { return(RedirectToAction(ActionNames.CreditCard, ControllerNames.CheckoutCreditCard)); } var customer = HttpContext.GetCustomer(); if (!customer.Owns.Wallet(model.SelectedPaymentProfileId)) { throw new HttpException(403, "Forbidden"); } customer.UpdateCustomer(requestedPaymentMethod: AppLogic.ro_PMCreditCard); customer.ThisCustomerSession["ActivePaymentProfileId"] = model.SelectedPaymentProfileId.ToString(); var paymentProfile = WalletProvider.GetPaymentProfile(customer, model.SelectedPaymentProfileId); var checkoutContext = PersistedCheckoutContextProvider.LoadCheckoutContext(customer); var expirationDate = new DateTime( year: int.Parse(paymentProfile.ExpirationYear), month: int.Parse(paymentProfile.ExpirationMonth), day: DateTime.Now.Day); PersistedCheckoutContextProvider.SaveCheckoutContext( customer: customer, checkoutContext: new PersistedCheckoutContext( creditCard: new CreditCardDetails( name: string.Format("{0} {1}", customer.FirstName, customer.LastName), number: paymentProfile.CreditCardNumberMasked, issueNumber: null, cardType: paymentProfile.CardType, expirationDate: expirationDate, startDate: null, cvv: string.Empty), payPalExpress: checkoutContext.PayPalExpress, purchaseOrder: checkoutContext.PurchaseOrder, braintree: checkoutContext.Braintree, amazonPayments: null, termsAndConditionsAccepted: checkoutContext.TermsAndConditionsAccepted, over13Checked: checkoutContext.Over13Checked, shippingEstimateDetails: checkoutContext.ShippingEstimateDetails, offsiteRequiresBillingAddressId: null, offsiteRequiresShippingAddressId: null, email: checkoutContext.Email, selectedShippingMethodId: checkoutContext.SelectedShippingMethodId)); return(RedirectToAction(ActionNames.Index, ControllerNames.Checkout)); }
public ActionResult SelectWallet(WalletSelectViewModel model) { if (!ModelState.IsValid) { return(RedirectToAction(ActionNames.CreditCard, ControllerNames.CheckoutCreditCard)); } var customer = HttpContext.GetCustomer(); if (!customer.Owns.Wallet(model.SelectedPaymentProfileId)) { throw new HttpException(403, "Forbidden"); } customer.UpdateCustomer(requestedPaymentMethod: AppLogic.ro_PMCreditCard); customer.ThisCustomerSession["ActivePaymentProfileId"] = model.SelectedPaymentProfileId.ToString(); var paymentProfile = WalletProvider.GetPaymentProfile(customer, model.SelectedPaymentProfileId); var expirationDate = new DateTime( year: int.Parse(paymentProfile.ExpirationYear), month: int.Parse(paymentProfile.ExpirationMonth), day: DateTime.Now.Day); PersistedCheckoutContextProvider.SaveCheckoutContext( customer: customer, checkoutContext: new PersistedCheckoutContextBuilder() .From(PersistedCheckoutContextProvider.LoadCheckoutContext(customer)) .WithCreditCard(new CreditCardDetails( name: string.Format("{0} {1}", customer.FirstName, customer.LastName), number: paymentProfile.CreditCardNumberMasked, issueNumber: null, cardType: paymentProfile.CardType, expirationDate: expirationDate, startDate: null, cvv: string.Empty)) .WithoutAmazonPayments() .WithoutOffsiteRequiredBillingAddressId() .WithoutOffsiteRequiredShippingAddressId() .Build()); return(RedirectToAction(ActionNames.Index, ControllerNames.Checkout)); }
public WalletSelect(WalletSelectViewModel vm) { this.DataContext = vm; InitializeComponent(); this.OnLoaded(window => { window.AddEventPath <WalletVmAddedEvent>("添加了钱包后,如果添加的钱包是当前选中的币种的钱包则刷新钱包选择下拉列表的Vm内存", LogEnum.DevConsole, action: message => { if (message.Event.Source.CoinId == vm.Coin.Id) { vm.OnPropertyChanged(nameof(vm.QueryResults)); } }, this.GetType()); window.AddEventPath <WalletVmRemovedEvent>("删除了钱包后,如果删除的钱包是当前选中的币种的钱包则刷新钱包选择下拉列表的Vm内存", LogEnum.DevConsole, action: message => { if (message.Event.Source.CoinId == vm.Coin.Id) { vm.OnPropertyChanged(nameof(vm.QueryResults)); } }, this.GetType()); }); }
public WalletSelect(WalletSelectViewModel vm) { this.DataContext = vm; InitializeComponent(); }