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