/// <summary>
        /// Save PaymentInfo Entity
        /// </summary>
        /// <param name="item">Entity to save</param>
        /// <param name="errorMessage">Error Message</param>
        /// <returns>return true if save successfully, else return false</returns>
        public static bool Save(PaymentInfo item, out string errorMessage)
        {
            bool isValid = Validate(item, out errorMessage);

            if (isValid)
            {
                PaymentInfoDao.Save(item);
            }

            return isValid;
        }
Пример #2
0
 /// <summary>
 /// Saves a PaymentInfo to the data store.
 /// </summary>
 /// <param name="item">The item to save</param>
 public static void Save(PaymentInfo item)
 {
     if (item.IsItemModified)
     {
         if (item.PaymentInfoId == null)
         {
             item.PaymentInfoId = Insert(item);
         }
         else
         {
             Update(item);
         }
     }
 }
        /// <summary>
        /// Validate PaymentInfo Entity
        /// </summary>
        /// <param name="item">Entity to validate</param>
        /// <param name="errorMessage">error message if vlidation failed</param>
        /// <returns>return true if entity passes validation logic, else return false</returns>
        public static bool Validate(PaymentInfo item, out string errorMessage)
        {
            StringBuilder builder = new StringBuilder();

            if (item.BillingAddress.IsNullOrWhiteSpace())
            {
                builder.AppendHtmlLine("*Billing Address is required");
            }

            if (item.BillingCity.IsNullOrWhiteSpace())
            {
                builder.AppendHtmlLine("*Billing City is required");
            }

            if (item.BillingState.IsNullOrWhiteSpace())
            {
                builder.AppendHtmlLine("*Billing State is required");
            }

            if (item.BillingZip.IsNullOrWhiteSpace())
            {
                builder.AppendHtmlLine("*Billing Zip is required");
            }

            if (item.CCV == default(int))
            {
                builder.AppendHtmlLine("*CCV is required");
            }

            if (item.CreditCardNumber.IsNullOrWhiteSpace())

            {
                builder.AppendHtmlLine("*Credit card number is required");
            }

            if (item.CreditCardType == EnumCreditCardType.None)
            {
                builder.AppendHtmlLine("*Credit card type is required");
            }

            if (!item.ExpirationDate.IsValidWithSqlDateStandards())

            {
                builder.AppendHtmlLine("*Expiration date is required");
            }

            if (item.UserId == default(Guid))
            {
                builder.AppendHtmlLine("*User Id is required");
            }

            errorMessage = builder.ToString();

            return errorMessage.IsNullOrWhiteSpace();
        }
Пример #4
0
        protected void grdPaymentInfo_OnUpdateCommand(object sender, GridCommandEventArgs e)
        {
            if (e.Item is GridDataItem &&
                e.Item.OwnerTableView.Name.SafeEquals("grdPaymentInfo", StringComparison.CurrentCultureIgnoreCase))
            {
                GridDataItem item = e.Item as GridDataItem;

                int paymentInfoId = (int)item.GetDataKeyValue("PaymentInfoId");

                HideErrorMessage(item);

                RadNumericTextBox txtCreditCardNumber = item.FindControl("txtCreditCardNumber") as RadNumericTextBox;

                RadDatePicker dtExpirationDate = item.FindControl("dtExpirationDate") as RadDatePicker;

                RadNumericTextBox txtCCV = item.FindControl("txtCCV") as RadNumericTextBox;

                RadTextBox txtBillingAddress = item.FindControl("txtBillingAddress") as RadTextBox;

                RadTextBox txtCity = item.FindControl("txtCity") as RadTextBox;

                RadTextBox txtZip = item.FindControl("txtZip") as RadTextBox;

                RadComboBox ddlStates = item.FindControl("ddlStates") as RadComboBox;

                RadComboBox ddlCreditCardType = item.FindControl("ddlCreditCardType") as RadComboBox;

                bool canEdit = txtBillingAddress != null && dtExpirationDate != null && txtCCV != null &&
                                              txtCity != null && txtZip != null && txtCreditCardNumber != null && ddlStates != null && ddlCreditCardType != null;

                if (canEdit)
                {
                    PaymentInfo info = new PaymentInfo
                    {
                        BillingAddress = txtBillingAddress.Text,
                        BillingCity = txtCity.Text,
                        BillingState = ddlStates.SelectedValue,
                        UserId = UserId,
                        ExpirationDate = dtExpirationDate.SelectedDate.GetValueOrDefault(),
                        BillingZip = txtZip.Text,
                        CreditCardNumber = txtCreditCardNumber.Text,
                        CCV = Convert.ToInt32(txtCCV.Value),
                        IsItemModified = true,
                        CreditCardType = EnumerationsHelper.ConvertFromString<EnumCreditCardType>(ddlCreditCardType.Text)
                    };

                    info.PaymentInfoId = paymentInfoId;

                    string errorMessage;

                    if (!PaymentInfoManager.Save(info, out errorMessage))
                    {
                        ShowErrorMessage(item, errorMessage);

                        e.Canceled = true;
                    }
                }
                else
                {
                    ShowErrorMessage(item, "*There was a problem processing your request. Please try again.");

                    e.Canceled = true;
                }
            }
        }
Пример #5
0
 /// <summary>
 /// Updates a PaymentInfo
 /// </summary>
 /// <param name="item">The PaymentInfo item to save</param>
 private static void Update(PaymentInfo item)
 {
     List<SqlParameter> parameters
         = new List<SqlParameter>
             {
                 new SqlParameter("@PaymentInfoId", item.PaymentInfoId),
                 new SqlParameter("@UserId", item.UserId),
                 new SqlParameter("@CreditCardNumber", item.CreditCardNumber),
                 new SqlParameter("@CreditCardTypeId", item.CreditCardType),
                 new SqlParameter("@ExpirationDate", item.ExpirationDate),
                 new SqlParameter("@CCV", item.CCV),
                 new SqlParameter("@BillingAddress", item.BillingAddress),
                 new SqlParameter("@BillingCity", item.BillingCity),
                 new SqlParameter("@BillingState", item.BillingState),
                 new SqlParameter("@BillingZip", item.BillingZip)
             };
     DataManager.ExecuteProcedure(ConferencePlusConnectionString, "PaymentInfo_Update", parameters);
 }
Пример #6
0
 /// <summary>
 /// Inserts a new PaymentInfo
 /// </summary>
 /// <param name="item">The PaymentInfo item to insert</param>
 /// <returns>The id of the PaymentInfo item just inserted</returns>
 private static int Insert(PaymentInfo item)
 {
     List<SqlParameter> parameters
         = new List<SqlParameter>
             {
                 new SqlParameter("@UserId", item.UserId),
                 new SqlParameter("@CreditCardNumber", item.CreditCardNumber),
                 new SqlParameter("@CreditCardTypeId", item.CreditCardType),
                 new SqlParameter("@ExpirationDate", item.ExpirationDate),
                 new SqlParameter("@CCV", item.CCV),
                 new SqlParameter("@BillingAddress", item.BillingAddress),
                 new SqlParameter("@BillingCity", item.BillingCity),
                 new SqlParameter("@BillingState", item.BillingState),
                 new SqlParameter("@BillingZip", item.BillingZip)
             };
     return Convert.ToInt32(DataManager.ExecuteScalarProcedure(ConferencePlusConnectionString, "PaymentInfo_Insert", parameters));
 }