public int CreateDay1(CreateTenantModel domainModel)
        {
            var username = ClaimsPrincipal.Current.Identity.SplitName();

            // Create repositories
            var tenantRepository = new TenantRepository();
            var userAccountRepository = new UserAccountRepository();
            var creditCardRepository = new CreditCardRepository();

            // Get the User
            var user = userAccountRepository.Fetch(username);

            // Create the Tenant
            var tenantId = tenantRepository.Create(user.UserAccountId, domainModel.Tenant);

            // Create the CreditCard
            if (!string.IsNullOrEmpty(domainModel.CreditCard.CreditCardNumber))
            {
                creditCardRepository.Insert(tenantId, domainModel.CreditCard);
            }

            // Update the User
            userAccountRepository.UpdatePesonalDetails(username, domainModel.UserAccount.Firstname, domainModel.UserAccount.Lastname);

            return tenantId;
        }
        public int Insert(int tenantId, CreateTenantModel.CreditCardModel domainModel)
        {
            // Build up the parameters
            var parameters = new List<SqlParameter>()
            {
                CreateParameter("@TenantId", SqlDbType.Int, tenantId),
                CreateParameter("@CardNumber", SqlDbType.VarChar, domainModel.CreditCardNumber),
                CreateParameter("@ExpirationDate", SqlDbType.VarChar, domainModel.ExpiryDate),
                CreateParameter("@CardVerificationValue", SqlDbType.VarChar, domainModel.CardVerificationValue),
            };

            // Run command
            return InsertData("Sp_Insert_CreditCard", parameters);
        }
        public int CreateDay2(CreateTenantModel domainModel)
        {
            var username = ClaimsPrincipal.Current.Identity.SplitName();

            // Create repositories
            var tenantRepository = new TenantRepository();
            var userAccountRepository = new UserAccountRepository();

            // Get the User
            var user = userAccountRepository.Fetch(username);

            // Create the Tenant
            var tenantId = tenantRepository.Create(user.UserAccountId, domainModel.Tenant);

            return tenantId;
        }
        public int Create(int userAccountId, CreateTenantModel.TenantModel domainModel)
        {
            // Build up the parameters
            var parameters = new List<SqlParameter>()
            {
                CreateParameter("@UserAccountId", SqlDbType.Int, userAccountId),
                CreateParameter("@ProvisioningOptionId", SqlDbType.VarChar, domainModel.ProvisioningOptionId),
                CreateParameter("@ThemeId", SqlDbType.VarChar, domainModel.ThemeId),
                CreateParameter("@SiteName", SqlDbType.VarChar, domainModel.SiteName),
                CreateParameter("@DataCenter", SqlDbType.VarChar, domainModel.DataCenter),
                CreateParameter("@OrganizationId", SqlDbType.VarChar, domainModel.OrganizationId),
                CreateParameter("@SubscriptionId", SqlDbType.VarChar, domainModel.SubscriptionId)
            };

            // Run command
            return InsertData("Sp_Insert_Tenant", parameters);
        }