Esempio n. 1
0
        public bool AddUserToStoreByEmail(long storeId, string email, StoreAccessMode mode)
        {
            UserAccount u = AdminUsers.FindByEmail(email);

            if (u == null)
            {
                u       = new UserAccount();
                u.Email = email;
                string password = Utilities.PasswordGenerator.GeneratePassword();
                u.HashedPassword = password;
                AdminUsers.Create(u);
            }

            if (AddUserToStore(storeId, u.Id, mode))
            {
                Store s = Stores.FindById(storeId);
                Utilities.MailServices.SendAccountInformation(u, s);
                return(true);
            }

            return(false);
        }
Esempio n. 2
0
        private Store CreateIndividualStore()
        {
            Store s = null;

            string storeName = "www";

            s             = new Store();
            s.StoreName   = Text.ForceAlphaNumericOnly(storeName).ToLower();
            s.Status      = StoreStatus.Active;
            s.DateCreated = DateTime.UtcNow;
            s.PlanId      = 99;
            s.CustomUrl   = string.Empty;

            if (!Stores.Create(s))
            {
                throw new CreateStoreException("Unable to create store. Unknown error. Please contact an administrator for assistance.");
            }

            s = Stores.FindByStoreName(s.StoreName);
            if (s != null)
            {
                UserAccount mainAccount = new UserAccount();
                mainAccount.Email          = "*****@*****.**";
                mainAccount.HashedPassword = "******";
                mainAccount.Status         = UserAccountStatus.Active;
                AdminUsers.Create(mainAccount);
                mainAccount = AdminUsers.FindByEmail(mainAccount.Email);

                AddUserToStore(s.Id, mainAccount.Id, StoreAccessMode.Owner);

                s.Settings.FriendlyName                   = "My MerchantTribe Store";
                s.Settings.MailServer.FromEmail           = "*****@*****.**";
                s.Settings.LastOrderNumber                = 0;
                s.Settings.LogoImage                      = "[[default]]";
                s.Settings.LogoRevision                   = 0;
                s.Settings.UseLogoImage                   = false;
                s.Settings.LogoText                       = s.StoreName;
                s.Settings.MinumumOrderAmount             = 0;
                s.Settings.MailServer.EmailForGeneral     = mainAccount.Email;
                s.Settings.MailServer.EmailForNewOrder    = mainAccount.Email;
                s.Settings.MailServer.UseCustomMailServer = false;
                s.Settings.ProductReviewCount             = 3;
                s.Settings.ProductReviewModerate          = true;
                s.Settings.ProductReviewShowRating        = true;
                s.Settings.PayPal.FastSignupEmail         = mainAccount.Email;
                s.Settings.PayPal.Currency                = "USD";
                s.Settings.MaxItemsPerOrder               = 999;
                s.CurrentPlanRate       = 0;
                s.CurrentPlanDayOfMonth = DateTime.Now.Day;
                s.CurrentPlanPercent    = 0;

                // Save data to store
                Stores.Update(s);

                // No longer need to redirect because home controller handles this
                //System.Web.HttpContext.Current.Response.Redirect("~/adminaccount/login?wizard=1");

                // Force this store into the request context so
                // non-repository datalayer will read in the correct
                // store id
                //RequestContext demoContext = new RequestContext();
                //demoContext.CurrentStore = s;
                //RequestContext.ForceCurrentRequestContext(demoContext);

                //// Add Sample Data
                //AddSampleProductsToStore(demoContext);

                //// Set a default theme
                //Content.ThemeManager m = new Content.ThemeManager(demoContext);
                //m.InstallTheme("cf09d318-3792-47b8-a207-a9502f96f0f9");
            }

            return(s);
        }