Пример #1
0
        private static int?CalculateCustomerHubID(int organizationID, int?customerHubID, int?productFamilyID)
        {
            int?customerHubIDToProcess = null;

            //If we have a hubID that is the best possible scenario
            if (customerHubID != null)
            {
                customerHubIDToProcess = customerHubID;
            }
            //Try by productFamilyID
            else if (productFamilyID != null && productFamilyID != -1)
            {
                CustomerHubs hubHelper = new CustomerHubs(LoginUser.Anonymous);
                hubHelper.LoadByProductFamilyID((int)productFamilyID);

                //because who doesn't love doing it this way!?
                if (hubHelper.Any())
                {
                    customerHubIDToProcess = hubHelper[0].CustomerHubID;
                }
            }
            //Try and choose the first hub that is not product line associated if no other options are met
            else
            {
                customerHubIDToProcess = CustomerHubs.LoadFirstNonProductAssociatedHubID(organizationID);
            }

            return(customerHubIDToProcess);
        }
Пример #2
0
        public static int?LoadFirstNonProductAssociatedHubID(int organizationID)
        {
            CustomerHubs customerHubHelper = new CustomerHubs(LoginUser.Anonymous);

            customerHubHelper.LoadByOrganizationID(organizationID);

            CustomerHub returnHub = customerHubHelper.Where(hub => hub.ProductFamilyID == null && hub.IsActive == true).First();

            return(returnHub?.CustomerHubID);
        }
        public static void DeleteByCustomerHubID(LoginUser loginUser, int customerHubID)
        {
            CustomerHubs customerHubs = new CustomerHubs(loginUser);

            using (SqlCommand command = new SqlCommand())
            {
                command.CommandText = "Delete FROM [CustomerHubAuthentication] WHERE CustomerHubID = @CustomerHubID";
                command.CommandType = CommandType.Text;
                command.Parameters.AddWithValue("@CustomerHubID", customerHubID);
                customerHubs.ExecuteNonQuery(command, "CustomerHubAuthentication");
            }
        }
Пример #4
0
        public static CustomerHub GetCustomerHub(LoginUser loginUser, int customerHubID)
        {
            CustomerHubs customerHubs = new CustomerHubs(loginUser);

            customerHubs.LoadByCustomerHubID(customerHubID);
            if (customerHubs.IsEmpty)
            {
                return(null);
            }
            else
            {
                return(customerHubs[0]);
            }
        }
Пример #5
0
 public CustomerHub(DataRow row, CustomerHubs customerHubs) : base(row, customerHubs)
 {
     _customerHubs = customerHubs;
 }