Example #1
0
        public static bool ActivateTheme(this SystemAdminBaseController controller, int themeId)
        {
            Theme theme = controller.GStoreDb.Themes.FindById(themeId);

            if (theme == null)
            {
                controller.AddUserMessage("Activate Theme Failed!", "Theme not found by id: " + themeId, AppHtmlHelpers.UserMessageType.Danger);
                return(false);
            }

            if (theme.IsActiveDirect())
            {
                controller.AddUserMessage("Theme is already active.", "Theme is already active. id: " + themeId, AppHtmlHelpers.UserMessageType.Info);
                return(false);
            }

            theme.IsPending        = false;
            theme.StartDateTimeUtc = DateTime.UtcNow.AddMinutes(-1);
            theme.EndDateTimeUtc   = DateTime.UtcNow.AddYears(100);
            controller.GStoreDb.Themes.Update(theme);
            controller.GStoreDb.SaveChanges();
            controller.AddUserMessage("Activated Theme", "Activated Theme '" + theme.Name.ToHtml() + "' [" + theme.ThemeId + "]" + " - Client '" + theme.Client.Name.ToHtml() + "' [" + theme.Client.ClientId + "]", AppHtmlHelpers.UserMessageType.Info);

            return(true);
        }
        public static IEnumerable <SelectListItem> ClientList(this HtmlHelper htmlHelper, int?selectedClientId, bool onlyWithstoreFronts = false)
        {
            SystemAdminBaseController controller = htmlHelper.ViewContext.Controller as SystemAdminBaseController;

            if (controller == null)
            {
                throw new NullReferenceException("Controller does not inherit from SystemAdminBaseController");
            }
            IQueryable <Client> query = null;

            if (onlyWithstoreFronts)
            {
                query = controller.GStoreDb.Clients.Where(c => c.StoreFronts.Any());
            }
            else
            {
                query = controller.GStoreDb.Clients.All();
            }
            List <Client> clients = query.ApplyDefaultSort().ToList();

            return(clients.Select(c => new SelectListItem()
            {
                Value = c.ClientId.ToString(),
                Selected = (selectedClientId.HasValue && selectedClientId.Value == c.ClientId),
                Text = c.Name + " [" + c.ClientId + "]" + (c.IsActiveDirect() ? "" : " [INACTIVE]") + " Store Fronts: " + c.StoreFronts.Count()
            }));
        }
Example #3
0
        public static bool ActivateStoreFrontConfigOnly(this SystemAdminBaseController controller, int storeConfigId)
        {
            StoreFrontConfiguration config = controller.GStoreDb.StoreFrontConfigurations.FindById(storeConfigId);

            if (config == null)
            {
                controller.AddUserMessage("Activate Store Config Failed!", "Store Config not found by id: " + storeConfigId, AppHtmlHelpers.UserMessageType.Danger);
                return(false);
            }

            if (config.IsActiveDirect())
            {
                controller.AddUserMessage("Store Config is already active.", "Store Config is already active. id: " + storeConfigId, AppHtmlHelpers.UserMessageType.Info);
                return(false);
            }

            config.IsPending        = false;
            config.StartDateTimeUtc = DateTime.UtcNow.AddMinutes(-1);
            config.EndDateTimeUtc   = DateTime.UtcNow.AddYears(100);
            config = controller.GStoreDb.StoreFrontConfigurations.Update(config);
            controller.GStoreDb.SaveChanges();
            controller.AddUserMessage("Activated Store Config", "Activated Store Config '" + config.ConfigurationName + "' [" + config.StoreFrontConfigurationId + "] for Store Front: '" + config.Name.ToHtml() + "' [" + config.StoreFrontId + "]" + " - Client '" + config.Client.Name.ToHtml() + "' [" + config.Client.ClientId + "]", AppHtmlHelpers.UserMessageType.Info);

            return(true);
        }
Example #4
0
        public static bool ActivateStoreFrontOnly(this SystemAdminBaseController controller, int storeFrontId)
        {
            StoreFront storeFront = controller.GStoreDb.StoreFronts.FindById(storeFrontId);

            if (storeFront == null)
            {
                controller.AddUserMessage("Activate Store Front Failed!", "Store Front not found by id: " + storeFrontId, AppHtmlHelpers.UserMessageType.Danger);
                return(false);
            }

            if (storeFront.IsActiveDirect())
            {
                controller.AddUserMessage("Store Front is already active.", "Store Front is already active. id: " + storeFrontId, AppHtmlHelpers.UserMessageType.Info);
                return(false);
            }

            storeFront.IsPending        = false;
            storeFront.StartDateTimeUtc = DateTime.UtcNow.AddMinutes(-1);
            storeFront.EndDateTimeUtc   = DateTime.UtcNow.AddYears(100);
            controller.GStoreDb.StoreFronts.Update(storeFront);
            controller.GStoreDb.SaveChanges();
            controller.AddUserMessage("Activated Store Front", "Activated Store Front '" + (storeFront.CurrentConfig() == null ? "" : storeFront.CurrentConfig().Name.ToHtml()) + "' [" + storeFront.ClientId + "]" + " - Client '" + storeFront.Client.Name.ToHtml() + "' [" + storeFront.Client.ClientId + "]", AppHtmlHelpers.UserMessageType.Info);

            return(true);
        }
Example #5
0
        public static bool ActivateWebFormField(this SystemAdminBaseController controller, int webFormFieldId)
        {
            WebFormField webFormField = controller.GStoreDb.WebFormFields.FindById(webFormFieldId);

            if (webFormField == null)
            {
                controller.AddUserMessage("Activate Web Form Field Failed!", "Web Form Field not found by id: " + webFormFieldId, AppHtmlHelpers.UserMessageType.Danger);
                return(false);
            }

            if (webFormField.IsActiveDirect())
            {
                controller.AddUserMessage("Web Form Field is already active.", "Web Form Field is already active. id: " + webFormFieldId, AppHtmlHelpers.UserMessageType.Info);
                return(false);
            }

            webFormField.IsPending        = false;
            webFormField.StartDateTimeUtc = DateTime.UtcNow.AddMinutes(-1);
            webFormField.EndDateTimeUtc   = DateTime.UtcNow.AddYears(100);
            controller.GStoreDb.WebFormFields.Update(webFormField);
            controller.GStoreDb.SaveChanges();
            controller.AddUserMessage("Activated Web Form Field", "Activated Web Form Field '" + webFormField.Name.ToHtml() + "' [" + webFormField.WebFormFieldId + "]" + " - Web Form '" + webFormField.WebForm.Name.ToHtml() + "' [" + webFormField.WebForm.WebFormId + "]", AppHtmlHelpers.UserMessageType.Info);

            return(true);
        }
Example #6
0
        public static bool ActivateValueListItem(this SystemAdminBaseController controller, int valueListItemId)
        {
            ValueListItem valueListItem = controller.GStoreDb.ValueListItems.FindById(valueListItemId);

            if (valueListItem == null)
            {
                controller.AddUserMessage("Activate Value List Item Failed!", "Value List Item not found by id: " + valueListItemId, AppHtmlHelpers.UserMessageType.Danger);
                return(false);
            }

            if (valueListItem.IsActiveDirect())
            {
                controller.AddUserMessage("Value List Item is already active.", "Value List Item is already active. id: " + valueListItemId, AppHtmlHelpers.UserMessageType.Info);
                return(false);
            }

            valueListItem.IsPending        = false;
            valueListItem.StartDateTimeUtc = DateTime.UtcNow.AddMinutes(-1);
            valueListItem.EndDateTimeUtc   = DateTime.UtcNow.AddYears(100);
            controller.GStoreDb.ValueListItems.Update(valueListItem);
            controller.GStoreDb.SaveChanges();
            controller.AddUserMessage("Activated Value List Item", "Activated Value List Item '" + valueListItem.Name.ToHtml() + "' [" + valueListItem.ValueListItemId + "]" + " - Value List '" + valueListItem.ValueList.Name.ToHtml() + "' [" + valueListItem.ValueList.ValueListId + "]", AppHtmlHelpers.UserMessageType.Info);

            return(true);
        }
Example #7
0
        public static bool ActivatePageTemplateSection(this SystemAdminBaseController controller, int pageTemplateSectionId)
        {
            PageTemplateSection pageTemplateSection = controller.GStoreDb.PageTemplateSections.FindById(pageTemplateSectionId);

            if (pageTemplateSection == null)
            {
                controller.AddUserMessage("Activate Page Template Section Failed!", "Page Template Section not found by id: " + pageTemplateSectionId, AppHtmlHelpers.UserMessageType.Danger);
                return(false);
            }

            if (pageTemplateSection.IsActiveDirect())
            {
                controller.AddUserMessage("Page Template Section is already active.", "Page Template Section is already active. id: " + pageTemplateSectionId, AppHtmlHelpers.UserMessageType.Info);
                return(false);
            }

            pageTemplateSection.IsPending        = false;
            pageTemplateSection.StartDateTimeUtc = DateTime.UtcNow.AddMinutes(-1);
            pageTemplateSection.EndDateTimeUtc   = DateTime.UtcNow.AddYears(100);
            controller.GStoreDb.PageTemplateSections.Update(pageTemplateSection);
            controller.GStoreDb.SaveChanges();
            controller.AddUserMessage("Activated Page Template Section", "Activated Page Template Section '" + pageTemplateSection.Name.ToHtml() + "' [" + pageTemplateSection.PageTemplateId + "] - Page Template '" + pageTemplateSection.PageTemplate.Name.ToHtml() + "' [" + pageTemplateSection.PageTemplate.PageTemplateId + "]", AppHtmlHelpers.UserMessageType.Info);

            return(true);
        }
Example #8
0
        public static bool ActivateUserProfile(this SystemAdminBaseController controller, int userProfileId)
        {
            UserProfile userProfile = controller.GStoreDb.UserProfiles.FindById(userProfileId);

            if (userProfile == null)
            {
                controller.AddUserMessage("User Profile Activation Failed!", "User Profile not found by id: " + userProfileId, AppHtmlHelpers.UserMessageType.Danger);
                return(false);
            }

            if (userProfile.IsActiveDirect())
            {
                controller.AddUserMessage("User Profile is already active.", "User Profile is already active. id: " + userProfileId, AppHtmlHelpers.UserMessageType.Info);
                return(false);
            }

            userProfile.IsPending        = false;
            userProfile.StartDateTimeUtc = DateTime.UtcNow.AddMinutes(-1);
            userProfile.EndDateTimeUtc   = DateTime.UtcNow.AddYears(100);
            controller.GStoreDb.UserProfiles.Update(userProfile);
            controller.GStoreDb.SaveChanges();
            controller.AddUserMessage("Activated User Profile", "Activated User Profile '" + userProfile.UserName.ToHtml() + "' [" + userProfile.UserProfileId + "]", AppHtmlHelpers.UserMessageType.Info);

            return(true);
        }
        public static MvcHtmlString Breadcrumbs(this HtmlHelper htmlHelper)
        {
            SystemAdminBaseController controller = htmlHelper.ViewContext.Controller as SystemAdminBaseController;

            if (controller == null)
            {
                return(new MvcHtmlString(""));
            }
            return(controller.Breadcrumbs(htmlHelper));
        }
        public static int?FilterClientId(this HtmlHelper htmlHelper)
        {
            SystemAdminBaseController controller = htmlHelper.ViewContext.Controller as SystemAdminBaseController;

            if (controller == null)
            {
                throw new NullReferenceException("Controller does not inherit from SystemAdminBaseController");
            }

            return(controller.FilterClientId());
        }
        public static IEnumerable <SelectListItem> StoreFrontFilterListForRecordSummary(this HtmlHelper htmlHelper, int?clientId, int?storeFrontId, string labelForAll = "(ALL)", string labelForNull = "(NONE)")
        {
            SystemAdminBaseController controller = htmlHelper.ViewContext.Controller as SystemAdminBaseController;

            if (controller == null)
            {
                throw new NullReferenceException("Controller does not inherit from SystemAdminBaseController");
            }

            return(controller.StoreFrontFilterList(clientId, storeFrontId, labelForAll, labelForNull));
        }
Example #12
0
        public static StoreBinding AutoMapBindingSeedBestGuessStoreFront(this SystemAdminBaseController controller)
        {
            StoreBinding binding = controller.GStoreDb.AutoMapBinding(controller);

            StoreFront storeFront = binding.StoreFront;
            string     message    = string.Empty;

            if (Settings.AppEnableBindingAutoMapCatchAll)
            {
                message = " to catch-all binding";
            }
            else
            {
                message = " to current Url";
            }
            string storeFrontName = storeFront.CurrentConfig() == null ? "No config found for Store Front Id: " + storeFront.StoreFrontId  : storeFront.CurrentConfig().Name;

            controller.AddUserMessage("AutoMapBindingSeedBestGuessStoreFront Success!", "Auto-mapped" + message.ToHtml() + " store binding to best guess store front '" + storeFrontName.ToHtml() + "' [" + storeFront.StoreFrontId + "]", AppHtmlHelpers.UserMessageType.Success);

            return(binding);
        }
Example #13
0
        public static bool ActivateStoreFrontClientBindingAndConfig(this SystemAdminBaseController controller, StoreBinding binding)
        {
            if (controller == null)
            {
                throw new NullReferenceException("controller");
            }
            if (binding == null)
            {
                throw new ArgumentNullException("binding");
            }

            if (binding.StoreFront.CurrentConfigOrAny() == null)
            {
                controller.AddUserMessage("Store Front Config Not Found", "No Configuration was found for Store Front Id: " + binding.StoreFrontId, AppHtmlHelpers.UserMessageType.Warning);
                return(false);
            }

            StoreFrontConfiguration config = binding.StoreFront.CurrentConfigOrAny();

            if (!config.IsActiveDirect())
            {
                config.IsPending        = false;
                config.StartDateTimeUtc = DateTime.UtcNow.AddMinutes(-1);
                config.EndDateTimeUtc   = DateTime.UtcNow.AddYears(100);
                config = controller.GStoreDb.StoreFrontConfigurations.Update(config);
                controller.GStoreDb.SaveChanges();
                controller.AddUserMessage("Activated Store Config", "Activated Store Front Configuration '" + config.ConfigurationName.ToHtml() + "' [" + config.StoreFrontConfigurationId + "]", AppHtmlHelpers.UserMessageType.Info);
            }

            if (!binding.IsActiveDirect())
            {
                binding.IsPending        = false;
                binding.StartDateTimeUtc = DateTime.UtcNow.AddMinutes(-1);
                binding.EndDateTimeUtc   = DateTime.UtcNow.AddYears(100);
                controller.GStoreDb.StoreBindings.Update(binding);
                controller.GStoreDb.SaveChanges();
                controller.AddUserMessage("Activated Store Binding", "Activated Store Binding Id: " + binding.StoreBindingId, AppHtmlHelpers.UserMessageType.Info);
            }

            if (!binding.Client.IsActiveDirect())
            {
                Client client = binding.Client;
                client.IsPending        = false;
                client.StartDateTimeUtc = DateTime.UtcNow.AddMinutes(-1);
                client.EndDateTimeUtc   = DateTime.UtcNow.AddYears(100);
                controller.GStoreDb.Clients.Update(client);
                controller.GStoreDb.SaveChanges();
                controller.AddUserMessage("Activated Client", "Activated Client '" + client.Name.ToHtml() + "' [" + client.ClientId + "]", AppHtmlHelpers.UserMessageType.Info);
            }

            if (!binding.StoreFront.IsActiveDirect())
            {
                StoreFront storeFront = binding.StoreFront;
                storeFront.IsPending        = false;
                storeFront.StartDateTimeUtc = DateTime.UtcNow.AddMinutes(-1);
                storeFront.EndDateTimeUtc   = DateTime.UtcNow.AddYears(100);
                controller.GStoreDb.StoreFronts.Update(storeFront);
                controller.GStoreDb.SaveChanges();
                controller.AddUserMessage("Activated Store Front", "Activated Store Front '" + storeFront.CurrentConfig().Name.ToHtml() + "' [" + storeFront.ClientId + "]", AppHtmlHelpers.UserMessageType.Info);
            }

            return(true);
        }