示例#1
0
        public ActionResult Create(CreateAssetViewModel viewModel)
        {
            if (!ModelState.IsValid)
            {
                return Create();
            }

            var newAsset = new Asset()
            {
                Name = viewModel.Name
            };

            _assetRepo.Add(newAsset);
            _assetRepo.SaveChanges();
            return Redirect(Url.Show(newAsset));
        }
示例#2
0
        public ActionResult Edit(EditAssetViewModel viewModel)
        {
            if (!ModelState.IsValid)
            {
                return Edit(viewModel.Id);
            }

            var assetToUpdate = new Asset()
            {
                Id = viewModel.Id,
                Name = viewModel.Name
            };

            _assetRepo.Update(assetToUpdate);
            _assetRepo.SaveChanges();
            return Redirect(Url.Show(assetToUpdate));
        }