Exemple #1
0
        public static bool ActivateStoreBindingOnly(this SystemAdminBaseController controller, int storeBindingId)
        {
            StoreBinding binding = controller.GStoreDb.StoreBindings.FindById(storeBindingId);

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

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

            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 Front", "Activated Store Binding [" + binding.StoreBindingId + "] "
                                      + " Store Front: '" + binding.StoreFront.CurrentConfigOrAny().Name.ToHtml() + "' [" + binding.StoreFront.StoreFrontId + "]" + " - Client '" + binding.Client.Name.ToHtml() + "' [" + binding.Client.ClientId + "]", AppHtmlHelpers.UserMessageType.Info);

            return(true);
        }
Exemple #2
0
        /// <summary>
        /// Returns true if store front and client (parent record) are both active
        /// </summary>
        /// <param name="storeFront"></param>
        /// <returns></returns>
        public static bool IsActiveBubble(this StoreBinding storeBinding)
        {
            if (storeBinding == null)
            {
                throw new ArgumentNullException("storeBinding");
            }

            return(storeBinding.IsActiveDirect() && storeBinding.StoreFront.IsActiveBubble());
        }
Exemple #3
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);
        }