Beispiel #1
0
        public static bool HasAddress(int userId, PaymentProcessorInfo processor)
        {
            int    count = 0;
            string query = "SELECT COUNT(*) FROM UsersPaymentProcessorsAddresses WHERE UserId = {0} AND ProcessorTypeInt = {1}";

            if (processor.IsAutomaticProcessor)
            {
                count = (int)TableHelper.SelectScalar(String.Format(query, userId, (int)processor.ProcessorType));
            }
            else
            {
                count = (int)TableHelper.SelectScalar(
                    String.Format(query + " AND CustomPayoutProcessorId = {2}", userId, (int)processor.ProcessorType, processor.CustomPayoutProcessorId));
            }

            return(count > 0);
        }
Beispiel #2
0
        public static UsersPaymentProcessorsAddress GetAddress(int userId, PaymentProcessorInfo processor)
        {
            UsersPaymentProcessorsAddress address;
            string query = "SELECT * FROM UsersPaymentProcessorsAddresses WHERE UserId = {0} AND ProcessorTypeInt = {1}";

            if (!HasAddress(userId, processor))
            {
                return(null);
            }

            if (processor.IsAutomaticProcessor)
            {
                address = TableHelper.GetListFromRawQuery <UsersPaymentProcessorsAddress>(String.Format(query, userId, (int)processor.ProcessorType))[0];
            }
            else
            {
                address = TableHelper.GetListFromRawQuery <UsersPaymentProcessorsAddress>(
                    String.Format(query + " AND CustomPayoutProcessorId = {2}", userId, (int)processor.ProcessorType, processor.CustomPayoutProcessorId))[0];
            }

            return(address);
        }
Beispiel #3
0
        public static void TrySetAddress(int userId, PaymentProcessorInfo processor, string address)
        {
            var CurrentAddress = GetAddress(userId, processor);

            if (CurrentAddress != null && CurrentAddress.PaymentAddress != address)
            {
                //Update
                CurrentAddress.PaymentAddress = address;
                CurrentAddress.LastChanged    = AppSettings.ServerTime;
                CurrentAddress.Save();
            }
            else
            {
                //Create new
                UsersPaymentProcessorsAddress NewAddress = new UsersPaymentProcessorsAddress();
                NewAddress.LastChanged             = AppSettings.ServerTime.AddYears(-10);
                NewAddress.UserId                  = userId;
                NewAddress.CustomPayoutProcessorId = processor.CustomPayoutProcessorId;
                NewAddress.PaymentAddress          = address;
                NewAddress.ProcessorTypeInt        = (int)processor.ProcessorType;
                NewAddress.Save();
            }
        }