private void AddAssetViewModel(AssetListViewModel viewModel, Asset asset) { var assetViewModel = new AssetViewModel(){Asset = asset}; foreach (var property in viewModel.Properties) { assetViewModel.SetPropertyValue(property, asset.GetPropertyValue(property.FullName)); } viewModel.AddAsset(assetViewModel); }
public ActionResult Create(string assetType, FormCollection values) { var viewModel = CreateAssetListViewModel(assetType, false); var asset = new Asset(viewModel.AssetType); foreach (var property in viewModel.Properties) { asset.GetPropertyValue(property.FullName).SystemValue = values[property.FullName]; } AssetService.AddAsset(asset); return RedirectToAction("Index", new{assetType}); }
public AssetPropertyValue(Asset asset, AssetProperty property) { Asset = asset; Property = property; if (property.Type != null) { if (property.IsCollection) { AssetValues = new List<Asset>(); } else { AssetValue = new Asset(property.Type); } } }
public void RemoveAsset(Asset asset) { AssetRepository.Remove(asset); }
public void AddAsset(Asset asset) { AssetRepository.Add(asset); }