public ActionResult WidgetsByZone(WidgetZone widgetZone) { //model var model = new List<WidgetModel>(); var widgets = widgetService.GetAllByZone(widgetZone); foreach (var widget in widgets) { var widgetPlugin = widgetService.LoadWidgetPluginBySystemName(widget.PluginSystemName); if (widgetPlugin == null || !widgetPlugin.PluginDescriptor.Installed) continue; //don't throw an exception. just process next widget. var widgetModel = new WidgetModel(); string actionName; string controllerName; RouteValueDictionary routeValues; widgetPlugin.GetDisplayWidgetRoute(widget.RowId, out actionName, out controllerName, out routeValues); widgetModel.ActionName = actionName; widgetModel.ControllerName = controllerName; widgetModel.RouteValues = routeValues; model.Add(widgetModel); } return PartialView(model); }
private void OnGameModelChanged() { LoadFormItems(); WidgetModel.SetChanges(); }
/// <summary> /// Invokes the view component /// </summary> /// <param name="widgetZone">Widget zone name</param> /// <param name="additionalData">Additional data</param> /// <returns>The <see cref="Task"/> containing the <see cref="IViewComponentResult"/></returns> public async Task <IViewComponentResult> InvokeAsync(string widgetZone, object additionalData) { if (!await _openPayService.CanDisplayWidgetAsync()) { return(Content(string.Empty)); } if (widgetZone == PublicWidgetZones.BodyEndHtmlTagBefore) { if (!_openPayPaymentSettings.DisplayLandingPageWidget) { return(Content(string.Empty)); } return(View("~/Plugins/Payments.OpenPay/Views/Widget/LandingPageLink.cshtml")); } var region = Defaults.OpenPay.AvailableRegions.FirstOrDefault( region => region.IsSandbox == _openPayPaymentSettings.UseSandbox && region.TwoLetterIsoCode == _openPayPaymentSettings.RegionTwoLetterIsoCode); var workingCurrency = await _workContext.GetWorkingCurrencyAsync(); Task <decimal> toWorkingCurrencyAsync(decimal price) => _currencyService.ConvertFromPrimaryStoreCurrencyAsync(price, workingCurrency); var model = new WidgetModel { WidgetCode = region.WidgetCode, RegionCode = region.TwoLetterIsoCode, CurrencyCode = workingCurrency.CurrencyCode, CurrencyFormatting = workingCurrency.CustomFormatting, PlanTiers = _openPayPaymentSettings.PlanTiers.Split(',').Select(x => int.Parse(x)).ToArray(), MinEligibleAmount = await toWorkingCurrencyAsync(_openPayPaymentSettings.MinOrderTotal), MaxEligibleAmount = await toWorkingCurrencyAsync(_openPayPaymentSettings.MaxOrderTotal), Type = "Online" }; if (widgetZone == PublicWidgetZones.ProductDetailsBottom && additionalData is ProductDetailsModel productDetailsModel) { if (!_openPayPaymentSettings.DisplayProductPageWidget) { return(Content(string.Empty)); } var product = await _productService.GetProductByIdAsync(productDetailsModel.Id); if (product == null || product.Deleted || product.IsDownload || !product.IsShipEnabled) { return(Content(string.Empty)); } model.Logo = _openPayPaymentSettings.ProductPageWidgetLogo; model.LogoPosition = _openPayPaymentSettings.ProductPageWidgetLogoPosition; model.Amount = productDetailsModel.ProductPrice.PriceValue; return(View("~/Plugins/Payments.OpenPay/Views/Widget/ProductPage.cshtml", model)); } if (widgetZone == PublicWidgetZones.ProductBoxAddinfoMiddle && additionalData is ProductOverviewModel productOverviewModel) { if (!_openPayPaymentSettings.DisplayProductListingWidget) { return(Content(string.Empty)); } var product = await _productService.GetProductByIdAsync(productOverviewModel.Id); if (product == null || product.Deleted || product.IsDownload || !product.IsShipEnabled) { return(Content(string.Empty)); } model.Logo = _openPayPaymentSettings.ProductListingWidgetLogo; model.HideLogo = _openPayPaymentSettings.ProductListingHideLogo; model.Amount = productOverviewModel.ProductPrice.PriceValue ?? decimal.Zero; return(View("~/Plugins/Payments.OpenPay/Views/Widget/ProductListing.cshtml", model)); } if (widgetZone == PublicWidgetZones.OrderSummaryContentAfter) { if (!_openPayPaymentSettings.DisplayCartWidget) { return(Content(string.Empty)); } var routeName = HttpContext.GetEndpoint()?.Metadata.GetMetadata <RouteNameMetadata>()?.RouteName; if (routeName != Defaults.ShoppingCartRouteName) { return(Content(string.Empty)); } var customer = await _workContext.GetCurrentCustomerAsync(); var store = await _storeContext.GetCurrentStoreAsync(); var cart = await _shoppingCartService.GetShoppingCartAsync(customer, ShoppingCartType.ShoppingCart, store.Id); if (cart == null || !cart.Any()) { return(Content(string.Empty)); } if (!await _shoppingCartService.ShoppingCartRequiresShippingAsync(cart)) { return(Content(string.Empty)); } var shoppingCartTotal = decimal.Zero; var cartTotal = await _orderTotalCalculationService.GetShoppingCartTotalAsync(cart); if (cartTotal.shoppingCartTotal.HasValue) { shoppingCartTotal = cartTotal.shoppingCartTotal.Value; } else { var cartSubTotal = await _orderTotalCalculationService.GetShoppingCartSubTotalAsync(cart, true); shoppingCartTotal = cartSubTotal.subTotalWithDiscount; } model.Logo = _openPayPaymentSettings.CartWidgetLogo; model.Amount = await toWorkingCurrencyAsync(shoppingCartTotal); return(View("~/Plugins/Payments.OpenPay/Views/Widget/Cart.cshtml", model)); } if (widgetZone == PublicWidgetZones.BodyStartHtmlTagAfter) { if (!_openPayPaymentSettings.DisplayInfoBeltWidget) { return(Content(string.Empty)); } model.Color = _openPayPaymentSettings.InfoBeltWidgetColor; return(View("~/Plugins/Payments.OpenPay/Views/Widget/InfoBelt.cshtml", model)); } if (widgetZone == "OpenPayLandingPage") { if (!_openPayPaymentSettings.DisplayLandingPageWidget) { return(Content(string.Empty)); } return(View("~/Plugins/Payments.OpenPay/Views/Widget/LandingPage.cshtml", model)); } return(Content(string.Empty)); }
public UnknownWidgetViewModel(WidgetModel model) : base(model, null) { }
public WidgetTv(WidgetModel widget, Dictionary <string, string> cachedUrls) : base(widget) { InitializeComponent(); _cachedUrls = cachedUrls ?? new Dictionary <string, string>(); }
void IWidgetHost.SaveWidgetDataMembers() { if (_userWidget != null) { List<dataStore> SettingsToSave = new List<dataStore>(); WidgetModel wm = new WidgetModel(); Ektron.Cms.PageBuilder.WidgetHost wh = new Ektron.Cms.PageBuilder.WidgetHost(); if (wh.SaveWidgetProperties(ref _userWidget, out SettingsToSave)) { (this as IWidgetHost).Save(dataStore.Serialize(SettingsToSave)); } } }
void IWidgetHost.LoadWidgetDataMembers() { if (_userWidget != null) { WidgetTypeModel widgetTypeModel = new WidgetTypeModel(); WidgetModel widgetModel = new WidgetModel(); WidgetTypeData widgettype = null; if (widgetTypeModel.FindByControlURL(_widget.ControlURL, out widgettype)) { Ektron.Cms.PageBuilder.WidgetHost wh = new Ektron.Cms.PageBuilder.WidgetHost(); wh.PopulateWidgetProperties(ref _userWidget, ref widgettype, _widget.Settings); } } }