protected override dynamic GetData() { string url = string.Format("/{0}", this.requestHandler.HttpContext.GetRouteValue("url")); Catalog catalog = this.requestHandler.Storage.GetRepository <ICatalogRepository>().WithUrl(url); if (catalog == null) { throw new HttpException(404, "Not found."); } ExpandoObjectBuilder expandoObjectBuilder = new ExpandoObjectBuilder(); expandoObjectBuilder.AddProperty("Name", this.requestHandler.GetLocalizationValue(catalog.NameId)); IProductProvider productProvider = StringActivator.CreateInstance <IProductProvider>(catalog.CSharpClassName); if (productProvider != null) { expandoObjectBuilder.AddProperty( "Products", productProvider.GetProducts(this.requestHandler, catalog).Select(p => this.CreateProductViewModel(p)).ToList() ); } return(expandoObjectBuilder.Build()); }
protected dynamic CreateSerializedObjectViewModel(SerializedObject serializedObject) { ExpandoObjectBuilder expandoObjectBuilder = new ExpandoObjectBuilder(); expandoObjectBuilder.AddProperty("Id", serializedObject.ObjectId); expandoObjectBuilder.AddProperty("ClassId", serializedObject.ClassId); foreach (SerializedProperty serializedProperty in JsonConvert.DeserializeObject <IEnumerable <SerializedProperty> >(serializedObject.SerializedProperties)) { if (serializedProperty.Member.PropertyDataTypeStorageDataType == StorageDataType.Integer) { expandoObjectBuilder.AddProperty(serializedProperty.Member.Code, serializedProperty.IntegerValue); } else if (serializedProperty.Member.PropertyDataTypeStorageDataType == StorageDataType.Decimal) { expandoObjectBuilder.AddProperty(serializedProperty.Member.Code, serializedProperty.DecimalValue); } else if (serializedProperty.Member.PropertyDataTypeStorageDataType == StorageDataType.String) { expandoObjectBuilder.AddProperty(serializedProperty.Member.Code, serializedProperty.StringValue); } else if (serializedProperty.Member.PropertyDataTypeStorageDataType == StorageDataType.DateTime) { expandoObjectBuilder.AddProperty(serializedProperty.Member.Code, serializedProperty.DateTimeValue); } } return(expandoObjectBuilder.Build()); }
private dynamic CreateViewModel(Endpoint endpoint) { ExpandoObjectBuilder expandoObjectBuilder = new ExpandoObjectBuilder(); foreach (DataSource dataSource in this.requestHandler.Storage.GetRepository <IDataSourceRepository>().FilteredByEndpointId(endpoint.Id).ToList()) { expandoObjectBuilder.AddProperty(dataSource.Code, this.CreateDataSourceViewModel(dataSource)); } return(expandoObjectBuilder.Build()); }
public static dynamic ToDisplayable(this Object @object) { ExpandoObjectBuilder expandoObjectBuilder = new ExpandoObjectBuilder(); foreach (Property property in @object.Properties) { if (property.Member.IsPropertyVisibleInList == true) { expandoObjectBuilder.AddProperty(property.Member.Code, property.GetValue()); } } return(expandoObjectBuilder.Build()); }
protected dynamic CreateViewModel(Object @object) { ExpandoObjectBuilder expandoObjectBuilder = new ExpandoObjectBuilder(); expandoObjectBuilder.AddProperty("Id", @object.Id); expandoObjectBuilder.AddProperty("ClassId", @object.ClassId); foreach (Property property in @object.Properties) { expandoObjectBuilder.AddProperty(property.Member.Code, property.GetValue()); } return(expandoObjectBuilder.Build()); }
private async Task <dynamic> CreateViewModelAsync(HttpContext httpContext, Data.Entities.Endpoint endpoint) { ExpandoObjectBuilder expandoObjectBuilder = new ExpandoObjectBuilder(); foreach (DataSource dataSource in endpoint.DataSources) { dynamic viewModel = await this.GetDataProvider(dataSource).GetDataAsync(httpContext, dataSource); if (viewModel == null) { return(null); } expandoObjectBuilder.AddProperty(dataSource.Code, viewModel); } return(expandoObjectBuilder.Build()); }