Exemplo n.º 1
0
        /// <summary>
        /// Handles the Click event of the btnSavePaymentInfo control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
        protected void btnSavePaymentInfo_Click(object sender, EventArgs e)
        {
            var    accountService  = new FinancialPersonSavedAccountService();
            var    configValues    = (Dictionary <string, object>)Session["CachedMergeFields"];
            string accountNickname = txtPaymentNick.Text;
            Person person          = FindPerson();

            var account = accountService.Queryable().Where(a => a.Name == accountNickname &&
                                                           a.PersonId == person.Id).FirstOrDefault();

            if (account == null)
            {
                account = new FinancialPersonSavedAccount();
                accountService.Add(account, person.Id);
            }

            account.Name = accountNickname;
            // #TODO WITH GATEWAY CALL
            account.TransactionCode = "Unknown";

            account.PersonId            = person.Id;
            account.MaskedAccountNumber = configValues["PaymentLastFour"].ToString();

            if (!string.IsNullOrEmpty(txtCreditCard.Text))
            {
                account.PaymentMethod = PaymentMethod.CreditCard;
            }
            else if (!string.IsNullOrEmpty(txtAccountNumber.Text))
            {
                account.PaymentMethod = PaymentMethod.ACH;
            }

            accountService.Save(account, person.Id);
            divPaymentNick.Visible = false;
        }