public ActionResult ActivateCurrentInactiveStoreFront() { if (CurrentStoreFrontOrNull != null) { AddUserMessage("Activate Current Inactive Store Front not needed!", "Current Store Front is Already Active.", UserMessageType.Warning); return(RedirectToAction("Index")); } List <StoreBinding> inactiveBindings = GStoreDb.GetInactiveStoreBindingMatches(Request); if (inactiveBindings == null || inactiveBindings.Count == 0) { AddUserMessage("ActivateCurrentInactiveStoreFront Failed!", "No inactive bindings found", UserMessageType.Danger); return(RedirectToAction("Index")); } StoreBinding binding = inactiveBindings[0]; bool result = this.ActivateStoreFrontClientBindingAndConfig(binding); if (result) { AddUserMessage("ActivateCurrentInactiveStoreFront Success!", "Re-activated store front '" + binding.StoreFront.CurrentConfigOrAny().Name.ToHtml() + "' [" + binding.StoreFront.StoreFrontId + "]", UserMessageType.Success); } else { AddUserMessage("ActivateCurrentInactiveStoreFront Failed!", "Could not re-activate store front [" + binding.StoreFront.StoreFrontId + "]\n<br/><a href=\"" + Url.Action("CreateConfig", "StoreFrontSysAdmin", new { id = binding.StoreFrontId }) + "\">Click here to create a new config for this store front</a>", UserMessageType.Danger); } return(RedirectToAction("Index")); }
public void Initialize(string[] skus) { if (debug) { Debug.Log("Initializing with skus " + skus); } this.productIdentifiers = skus; // Make sure the user has enabled purchases in their settings before doing anything if (StoreBinding.CanMakeStorePurchases()) { StoreBinding.LoadStore(gameObject.name, productIdentifiers); if (receiptServer != null) { Debug.Log("Adding Server Verification " + receiptServer); StoreBinding.SetReceiptVerificationServer(receiptServer.ToString()); } } else { Response r = new Response(); r.ok = false; r.code = CODE_FAILED; r.error = "CanMakeStorePurchases return false"; listener.OnReady(r); } }
public OutputModeEditor() { this.Content = new StackLayout { Padding = 5, Spacing = 5, HorizontalContentAlignment = HorizontalAlignment.Stretch, Items = { new StackLayoutItem(editorContainer, true), new StackLayoutItem(outputModeSelector, HorizontalAlignment.Left) } }; outputModeSelector.SelectedValueChanged += (sender, args) => { if (outputModeSelector.SelectedType is TypeInfo type) { this.Store = new PluginSettingStore(type); } }; outputModeSelector.SelectedTypeBinding.Bind( StoreBinding.Convert <TypeInfo>( c => c?.GetPluginReference().GetTypeReference(), t => PluginSettingStore.FromPath(t.FullName) ) ); }
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); }
public ActionResult Create(int?clientId, int?storeFrontId) { if (GStoreDb.Clients.IsEmpty()) { AddUserMessage("No Clients in database.", "You must create a Client and Store Front to add a store binding.", UserMessageType.Warning); return(RedirectToAction("Create", "ClientSysAdmin")); } if (GStoreDb.StoreFronts.IsEmpty()) { AddUserMessage("No Store Fronts in database.", "You must create a Store Front to add a store binding.", UserMessageType.Warning); return(RedirectToAction("Create", "StoreFrontSysAdmin")); } StoreBinding model = GStoreDb.StoreBindings.Create(); model.SetDefaultsForNew(Request, clientId, storeFrontId); this.BreadCrumbsFunc = html => this.BindingBreadcrumb(html, model.ClientId, model.StoreFront, model); if (clientId == null || clientId.Value == 0 || clientId.Value == -1) { Client firstClient = GStoreDb.Clients.Where(c => c.StoreFronts.Any()).ApplyDefaultSort().First(); model.Client = firstClient; model.ClientId = firstClient.ClientId; if (storeFrontId == null || storeFrontId.Value == 0) { StoreFront firstStoreFront = firstClient.StoreFronts.AsQueryable().ApplyDefaultSort().First(); model.StoreFront = firstStoreFront; model.StoreFrontId = firstStoreFront.StoreFrontId; } } return(View(model)); }
public ActionResult DeleteConfirmed(int id) { try { StoreBinding target = GStoreDb.StoreBindings.FindById(id); string storeFrontName = target.StoreFront.CurrentConfigOrAny().Name; if (target == null) { //storeBinding not found, already deleted? overpost? throw new ApplicationException("Error deleting Store Binding. Store Binding not found. It may have been deleted by another user. StoreBindingId: " + id); } bool deleted = GStoreDb.StoreBindings.DeleteById(id); GStoreDb.SaveChanges(); if (deleted) { AddUserMessage("Store Binding Deleted", "Store Binding for Store Front '" + storeFrontName.ToHtml() + "' Binding [" + id + "] was deleted successfully.", UserMessageType.Success); } } catch (Exception ex) { throw new ApplicationException("Error deleting StoreBinding. See inner exception for errors. Related child tables may still have data to be deleted. StoreBindingId: " + id, ex); } return(RedirectToAction("Index")); }
public void PurchaseAndConsume(string sku) { if (debug) { Debug.Log("PurchaseAndConsume " + sku); } StoreBinding.PurchaseProduct(sku); }
/// <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()); }
public void CallbackStoreLoadedSuccessfully(string empty) { // Called From Objective-C when the store has successfully finished loading StoreBinding.LoadStoreProductsWithInfo(productIdentifiers); Response r = new Response(); r.ok = true; listener.OnReady(r); }
public ActionResult BindSeedBestGuessStoreFront() { StoreBinding binding = this.AutoMapBindingSeedBestGuessStoreFront(); if (binding == null) { AddUserMessage("BindSeedBestGuessStoreFront Failed!", "BindSeedBestGuessStoreFront Failed!", UserMessageType.Danger); return(RedirectToAction("Index")); } AddUserMessage("BindSeedBestGuessStoreFront Success!", "Auto-mapped Binding successfully!", UserMessageType.Success); return(RedirectToAction("Index")); }
public void CallbackReceiveProductInfo(string info) { // Called From Objective-C After LoadStoreProductsWithInfo for each item StoreProduct product = StoreBinding.StringToProduct(info); products.Add(product); if (debug) { Debug.Log("Receive product info " + info); } }
public ActionResult Details(int?id) { if (id == null) { return(HttpBadRequest("Store Binding Id is null")); } StoreBinding storeBinding = GStoreDb.StoreBindings.FindById(id.Value); if (storeBinding == null) { return(HttpNotFound()); } this.BreadCrumbsFunc = html => this.BindingBreadcrumb(html, storeBinding.ClientId, storeBinding.StoreFront, storeBinding); return(View(storeBinding)); }
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); }
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) )); }