public ActionResult Create(StoreBinding storeBinding, bool? clientIdChanged, bool? storeFrontIdChanged) { if (ModelState.IsValid && !(clientIdChanged ?? false) && !(storeFrontIdChanged ?? false)) { storeBinding = GStoreDb.StoreBindings.Create(storeBinding); storeBinding.UpdateAuditFields(CurrentUserProfileOrThrow); storeBinding = GStoreDb.StoreBindings.Add(storeBinding); GStoreDb.SaveChanges(); AddUserMessage("Store Binding Added", "Store Binding [" + storeBinding.StoreBindingId + "] created successfully!", UserMessageType.Success); return RedirectToAction("Index"); } int? clientId = null; if (storeBinding.ClientId != default(int)) { clientId = storeBinding.ClientId; } if (clientIdChanged ?? false) { storeBinding.StoreFrontId = 0; storeBinding.StoreFrontConfigurationId = 0; } if (storeFrontIdChanged ?? false) { storeBinding.StoreFrontConfigurationId = 0; } int? storeFrontId = null; if (storeBinding.StoreFrontId != default(int)) { storeFrontId = storeBinding.StoreFrontId; } this.BreadCrumbsFunc = html => this.BindingBreadcrumb(html, storeBinding.ClientId, storeBinding.StoreFront, storeBinding); return View(storeBinding); }
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; }
protected MvcHtmlString BindingBreadcrumb(HtmlHelper htmlHelper, int? clientId, StoreFront storeFront, StoreBinding storeBinding, bool ShowAsLink = false) { RouteValueDictionary routeData = null; string name = "(unknown)"; bool showLink = false; if (storeBinding != null) { if (storeBinding.StoreBindingId == 0) { name = "New"; } else { showLink = ShowAsLink; routeData = new RouteValueDictionary(new { id = storeBinding.StoreBindingId }); name = "Binding [" + storeBinding.StoreBindingId + "]"; } } return new MvcHtmlString( BindingsBreadcrumb(htmlHelper, clientId, storeFront, true).ToHtmlString() + " -> " + (showLink ? htmlHelper.ActionLink(name, "Details", "BindingsSysAdmin", routeData, null).ToHtmlString() : name) ); }