private async Task BuildViewModelAsync(ProjectionEditPartViewModel model, ProjectionPart part, IUpdateModel modelUpdater) { var providers = _layoutsProviderManager.GetProviders(); model.AvailableVisualProviders.Clear(); foreach (var provider in providers) { VisualProfile visualProfile; if (part.ProviderName == provider.Name) { //pass in existing object config object from metadtaa visualProfile = JsonConvert.DeserializeObject <VisualProfile>(part.VisualMetadata, new JsonSerializerSettings { TypeNameHandling = TypeNameHandling.All, // $type no longer needs to be first MetadataPropertyHandling = MetadataPropertyHandling.ReadAhead }); } else { //instantiate new object visualProfile = provider.Create(); } var vm = new VisualsProviderViewModel { Editor = await _displayManager.BuildEditorAsync(visualProfile, modelUpdater, isNew : true), SourceName = provider.Name, VisualProfile = visualProfile }; model.AvailableVisualProviders.Add(provider.Name, vm); // dynamic shapemodel = await provider.Value.BuildEditorAsync( slidesProviderContext); // shapemodel.Provider = provider; } model.ContentItem = part.ContentItem; // model.ShortName = settings.ShortName; // model.ShowComments = part.ShowComments; model.Part = part; model.AvailableQueries = await _queryManager.ListQueriesAsync(); model.Query = part.Query; model.Hint = part.Hint; // model.DisplayType = part.DisplayType; model.ProviderName = part.ProviderName; model.Parameters = part.Parameters; model.ItemsPerPage = part.ItemsPerPage; model.Skip = part.Skip; // model.PagerSuffix = part.PagerSuffix; model.MaxItems = part.MaxItems; }
public override IDisplayResult Display(ProjectionPart projectionpart, BuildPartDisplayContext context) { var shapeName = !String.IsNullOrEmpty(projectionpart.ProviderName) ? "ProjectionPart" : "ProjectionPart_Empty"; return(Initialize <ProjectionDisplayPartViewModel>(shapeName, async model => { model.ProjectionPart = projectionpart; if (!String.IsNullOrEmpty(projectionpart.ProviderName)) { //pass in existing object config object from metadtaa var layoutProfile = JsonConvert.DeserializeObject <VisualProfile>(projectionpart.VisualMetadata, new JsonSerializerSettings { TypeNameHandling = TypeNameHandling.All, // $type no longer needs to be first MetadataPropertyHandling = MetadataPropertyHandling.ReadAhead }); //the actual query results layoutProfile.QueryResult = await QueryResult(projectionpart.Query, projectionpart.Parameters); var vm = new VisualsProviderViewModel { //here maybe create a content vm to pass in query results to display view Editor = await _displayManager.BuildDisplayAsync(layoutProfile, context.Updater, "Detail"), SourceName = projectionpart.ProviderName }; //in the shape editor pass in other properties to consume in the view //vm.Editor.Engine = _engineManager.GetEngineInstance(part.Profile); //vm.Editor.SlideshowId = part.ContentItem.Id.ToString(); //the shape editor model.DisplayVisualProvider = vm; //the actual query results // model.QueryResult= await QueryResult(listPart.Query, listPart.Parameters); } }) .Location("Detail", "Content:10")); //.Location("DetailAdmin", "Content:10"); }