Beispiel #1
0
        public IHttpActionResult AddPaymentMethod(PaymentMethodData payment_method_data)
        {
            if (payment_method_data.payment_method_data_id > 0)
            {
                return(Ok("This payment method has already been added."));
            }
            else
            {
                if (payment_method_data.cash_amount > 0)
                {
                    return(Ok("Cannot add additional cash payment method."));
                }
            }

            var ua = UserAccess.GetUserAccess(User.Identity.Name);

            if (!TransactionData.ValidateEdit(payment_method_data.transaction_id, ua))
            {
                return(Unauthorized());
            }

            payment_method_data.SetUserName(ua.user_name);

            if (ua.current_access == UserAccess.access_type.no_access)
            {
                return(Unauthorized());
            }

            if (!TransactionData.ValidateEdit(payment_method_data.transaction_id, ua))
            {
                return(Unauthorized());
            }

            if (!payment_method_data.ValidateNew())
            {
                if (payment_method_data.error_text.Length == 0)
                {
                    payment_method_data.error_text = "There was an issue with validating the payment method.";
                }
            }
            else
            {
                payment_method_data.added_after_save = true;

                if (!payment_method_data.SavePaymentMethod())
                {
                    if (payment_method_data.error_text.Length == 0)
                    {
                        payment_method_data.error_text = "There was an issue saving the new payment method.";
                    }
                }
            }

            return(Ok());
        }
Beispiel #2
0
        public IHttpActionResult EditPaymentMethod(PaymentMethodData payment_method_data)
        {
            if (payment_method_data.payment_method_data_id == -1)
            {
                return(BadRequest());
            }
            var ua = UserAccess.GetUserAccess(User.Identity.Name);

            if (!TransactionData.ValidateEdit(payment_method_data.transaction_id, ua))
            {
                return(Unauthorized());
            }

            //var user_ip_address = ((HttpContextWrapper)Request.Properties["MS_HttpContext"]).Request.UserHostAddress;
            payment_method_data.SetUserName(ua.user_name);

            if (ua.current_access == UserAccess.access_type.no_access)
            {
                return(Unauthorized());
            }
            if (!payment_method_data.ValidateChange())
            {
                if (payment_method_data.error_text.Length == 0)
                {
                    return(Ok("There was an issue with validating the payment method."));
                }
            }
            else
            {
                payment_method_data.added_after_save = false;
                if (!payment_method_data.SavePaymentMethod())
                {
                    if (payment_method_data.error_text.Length == 0)
                    {
                        return(Ok("There was an issue editing the payment method."));
                    }
                }
            }
            return(Ok());
        }