예제 #1
0
        public bool ValidateChangePaymentType(PaymentTypeData ptd)
        {
            // add new, additional checks here if we determine they need to be.


            return(true);
        }
예제 #2
0
        public IHttpActionResult AddPaymentType(List <PaymentTypeData> payment_types_data)
        {
            if (!payment_types_data.Any())
            {
                return(Ok(new TransactionData()
                {
                    error_text = "there are no payment types in the list"
                }));
            }

            var ua = UserAccess.GetUserAccess(User.Identity.Name);
            var user_ip_address = ((HttpContextWrapper)Request.Properties["MS_HttpContext"]).Request.UserHostAddress;

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

            // validate if user is able to edit or add payments to this transaction
            if (!TransactionData.ValidateEdit(payment_types_data[0].transaction_id, ua))
            {
                return(Unauthorized());
            }

            foreach (var pt in payment_types_data)
            {
                if (!pt.ValidateChangePaymentType())
                {
                    // probably should return the entire transaction with a save error
                    if (pt.error_text.Length > 0)
                    {
                        pt.error_text = "There was an issue with this payment type.";
                        return(Ok("There was an issue with the payment type data"));
                    }
                }
            }


            if (!PaymentTypeData.SaveChangePaymentTypeData(payment_types_data, ua, user_ip_address))
            {
                return(Ok("There was an issue saving the payment type data"));
            }

            return(Ok());
        }
예제 #3
0
        public List <PaymentType> PaymentType(string CompanySlug, List <object> Data)
        {
            string          result   = "";
            HttpWebResponse response = Http.SyncList(CompanySlug + "/upload/paymentType", Data);

            if (response.StatusCode != HttpStatusCode.OK)
            {
                HttpListenerException ex = new HttpListenerException();
                throw ex;
            }

            using (var streamReader = new StreamReader(response.GetResponseStream()))
            {
                result = streamReader.ReadToEnd();
            }

            Models.PaymentTypeData MyList = new PaymentTypeData();
            MyList = JsonConvert.DeserializeObject <Models.PaymentTypeData>(result);

            return(MyList.data);
        }