private void AddPropertyViewModels(AssetListViewModel viewModel, AssetType assetType, string parentName) { foreach (var property in assetType.Properties) { var fullName = parentName == null ? property.Name : new StringBuilder(parentName).Append(".").Append(property.Name).ToString(); if (property.ValueType != null || property.UnitOfMeasurement != null) AddPropertyToViewModel(viewModel, property, fullName, null); if (property.Type != null) { if (!property.Type.HasUniqueIdentifier) { AddPropertyViewModels(viewModel, property.Type, fullName); } else { var possibleValues = AssetService.GetAllAssetsByAssetType(property.Type).Select(x => new SelectListItem() { Value = x.UniqueIdentifier, Text = x.UniqueIdentifier }); AddPropertyToViewModel(viewModel, property, fullName, possibleValues); } } } }
public Asset(AssetType type) { Type = type; PropertyValues = new List<AssetPropertyValue>(); foreach (var assetProperty in type.Properties) { PropertyValues.Add(new AssetPropertyValue(this, assetProperty)); } }
public IEnumerable<Asset> GetAllAssetsByAssetType(AssetType type) { return AssetRepository.GetAll(type); }
public Asset FindAsset(AssetType assetType, string uniqueIdentifier) { return AssetRepository.Find(assetType, uniqueIdentifier); }