public static void RenderWidget(this HtmlHelper helper, Models.Widget widget, bool defer = false) { if (widget.IsAuthorized) { if (!defer) { widget.ClientId = Services.Portal.NextClientId(); try { helper.RenderPartial("Widgets/" + widget.Manifest.FullName, widget); helper.RegisterWebReferences(widget.WebReferences); } catch (Exception ex) { helper.RenderPartial("Widgets/Core/Error", widget, new ViewDataDictionary() { { "Exception", ex } }); } } else { DeferredWidgets.Add(widget); } } //return ""; }
public static Models.Widget FromViewModel(this ViewModels.Widget viewModel) { Models.Widget result = null; if (viewModel != null) { result = new Models.Widget(); result.Id = new MongoDB.Bson.ObjectId(viewModel.Id); result.Name = viewModel.Name; } return(result); }
//public static string RenderDeferredWidgets(this HtmlHelper helper) //{ // foreach (var widget in DeferredWidgets) // RenderWidget(helper, widget); // return ""; //TODO: return string????? //} public static void RenderWidget(this HtmlHelper helper, string manifestFullName, Dictionary <string, object> attributes = null, bool defer = false, string css = null, string style = null) { var manifest = Services.Portal.GetWidgetManifest(manifestFullName); var widget = new Models.Widget() { ManifestId = manifest.Id, Css = css, Style = style }; if (attributes != null) { widget.Attributes = attributes; } RenderWidget(helper, widget, defer); //return ""; }
public static ViewModels.Widget ToViewModel(this Models.Widget model) { ViewModels.Widget result = null; if (model != null) { result = new ViewModels.Widget(); result.Id = model.Id.ToString(); result.Name = model.Name; } return(result); }
IEnumerable <WeatherStation> GetSupportedStations(Models.Widget widget) { IEnumerable <WeatherStation> supportedStations; if (_context.HttpContext.User.Identity.IsAuthenticated) { supportedStations = _widgetProvider.GetSupportedStations(widget); } else { supportedStations = _widgetProvider.GetSupportedPublicStations(widget); } return(supportedStations); }
public CommentControl(Models.Widget widget, string containerType, string containerId, string portalId = null) { ClientId = Services.Portal.NextClientId(); Widget = widget; Provider = widget.GetAttribute("CommentProvider", "None"); if (Provider.Equals("Videre", StringComparison.InvariantCultureIgnoreCase)) { Container = Services.Comment.Get(containerType, containerId, portalId); if (Container == null) { Container = new CommentContainer() { ContainerType = containerType, ContainerId = containerId }; Services.Comment.Save(Container); } } }
public Models.Widget CreateWidget(Models.Widget c) { _db.GetCollection <Models.Widget>("Widgets").InsertOne(c); return(c); }
//public static string RenderDeferredWidgets(this HtmlHelper helper) //{ // foreach (var widget in DeferredWidgets) // RenderWidget(helper, widget); // return ""; //TODO: return string????? //} public static void RenderWidget(this HtmlHelper helper, string manifestFullName, Dictionary<string, object> attributes = null, bool defer = false, string css = null, string style = null) { var manifest = Services.Portal.GetWidgetManifest(manifestFullName); var widget = new Models.Widget() { ManifestId = manifest.Id, Css = css, Style = style }; if (attributes != null) widget.Attributes = attributes; RenderWidget(helper, widget, defer); //return ""; }