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}); }