Example #1
0
        public static ConstraintResponseType CheckUserConstraint(string accountId)
        {
            var response = new ConstraintResponseType {
                isConstrained = false
            };

            // Get the Account & the associated Plan:
            var account = AccountManager.GetAccount(accountId);
            var plan    = PaymentPlanManager.GetPaymentPlan(account.PaymentPlanName);

            int maxUsers = plan.MaxUsers;

            int userCount       = account.Users.Count;
            int invitationCount = AccountUserManager.GetInvitations(accountId, account.StoragePartition).Count;

            int totalAssociatedUsers = (userCount + invitationCount) - 1; //<--Offset by 1 to hide: platformadmin@[Config_PlatformEmail]  LEGACY: //<-- We remove 1 user from the validation as the account creator does not count in the constraint

            if (maxUsers <= totalAssociatedUsers)
            {
                response.isConstrained     = true;
                response.constraintMessage = "You have reached your limit of " + maxUsers + " users.";
            }


            return(response);
        }
Example #2
0
 public PaymentPlan GetPaymentPlan(string planName)
 {
     return(PaymentPlanManager.GetPaymentPlan(planName));
 }
Example #3
0
        public static Account DataReader_to_Account(SqlDataReader reader)
        {
            Account account = new Account();

            account.AccountName    = (String)reader["AccountName"];
            account.AccountNameKey = (String)reader["AccountNameKey"];
            account.AccountID      = (Guid)reader["AccountID"];


            #region Legacy Document Database Properties

            /*
             * if (reader["DocumentDatabaseLink"] != DBNull.Value)
             * {
             *  account.DocumentDatabaseLink = (String)reader["DocumentDatabaseLink"];
             * }
             * else
             * {
             *  account.DocumentDatabaseLink = null;
             * }
             *
             * if (reader["PropertiesCollectionLink"] != DBNull.Value)
             * {
             *  account.PropertiesCollectionLink = (String)reader["PropertiesCollectionLink"];
             * }
             * else
             * {
             *  account.PropertiesCollectionLink = null;
             * }
             *
             *
             * if (reader["SelfLinkReferencesDocumentLink"] != DBNull.Value)
             * {
             *  account.SelfLinkReferencesDocumentLink = (String)reader["SelfLinkReferencesDocumentLink"];
             * }
             * else
             * {
             *  account.SelfLinkReferencesDocumentLink = null;
             * }
             */

            #endregion


            #region Transform Stripe Payments Properties

            if (reader["StripeCustomerID"] != DBNull.Value)
            {
                account.StripeCustomerID = (String)reader["StripeCustomerID"];
            }
            else
            {
                account.StripeCustomerID = null;
            }

            if (reader["StripeSubscriptionID"] != DBNull.Value)
            {
                account.StripeSubscriptionID = (String)reader["StripeSubscriptionID"];
            }
            else
            {
                account.StripeSubscriptionID = null;
            }


            if (reader["StripeCardID"] != DBNull.Value)
            {
                account.StripeCardID = (String)reader["StripeCardID"];
            }
            else
            {
                account.StripeCardID = null;
            }

            #endregion

            account.Active      = (Boolean)reader["Active"];
            account.Provisioned = (Boolean)reader["Provisioned"];

            account.CreatedDate = (DateTime)reader["CreatedDate"];

            account.Closed          = ((Boolean)reader["Closed"]);
            account.ClosureApproved = ((Boolean)reader["ClosureApproved"]);
            account.Delinquent      = ((Boolean)reader["Delinquent"]);


            if (reader["CardExpiration"] != DBNull.Value)
            {
                account.CardExpiration = (DateTime)reader["CardExpiration"];
            }

            if (reader["LockedDate"] != DBNull.Value)
            {
                account.Locked = true;
            }
            else
            {
                account.Locked = false;
            }

            if (reader["Logo"] != DBNull.Value)
            {
                account.Logo = (String)reader["Logo"];
            }
            else
            {
                account.Logo = null;
            }


            account.PaymentPlanName        = ((string)reader["PaymentPlanName"]);
            account.PaymentFrequencyMonths = ((int)reader["PaymentFrequencyMonths"]);



            if (reader["AccountEndDate"] != DBNull.Value)
            {
                account.AccountEndDate = (DateTime)reader["AccountEndDate"];
            }

            if (reader["PhoneNumber"] != DBNull.Value)
            {
                account.PhoneNumber = (String)reader["PhoneNumber"];
            }


            if (reader["SqlPartition"] != DBNull.Value)
            {
                account.SqlPartition = (String)reader["SqlPartition"];
            }

            if (reader["StoragePartition"] != DBNull.Value)
            {
                account.StoragePartition = (String)reader["StoragePartition"];
            }

            if (reader["SearchPartition"] != DBNull.Value)
            {
                account.SearchPartition = (String)reader["SearchPartition"];
            }

            /*
             * if (reader["DocumentPartition"] != DBNull.Value)
             * {
             *  account.DocumentPartition = (String)reader["DocumentPartition"];
             *  //account.ProductSearchIndex = Common.Methods.Strings.ConvertDocumentCollectionNameToSearchIndexName(account.DocumentPartition);
             * }*/


            if (reader["ProvisionedDate"] != DBNull.Value)
            {
                account.ProvisionedDate = (DateTime)reader["ProvisionedDate"];
            }

            //Assign PaymentPlan & Frequency Objects
            try
            {
                account.PaymentPlan      = PaymentPlanManager.GetPaymentPlan(account.PaymentPlanName);
                account.PaymentFrequency = PaymentPlanManager.GetPaymentFrequency(account.PaymentFrequencyMonths.ToString());
            }
            catch (Exception e)
            {
                #region Log Exception

                PlatformExceptionsHelper.LogExceptionAndAlertAdmins(
                    e,
                    "attempting to retreive paymentplan or paymentfrequency object during transformations for Account object",
                    System.Reflection.MethodBase.GetCurrentMethod(),
                    account.AccountID.ToString(),
                    account.AccountName);

                #endregion
            }


            return(account);
        }