public ActionResult Create(ProductFeatureViewModel vm) { if (ModelState.IsValid) { var feature = new ProductFeature { ProductId = vm.ProductId }; converter.ViewmodelToEntity(vm, ref feature); service.Add(feature); return RedirectToAction("Edit", "Product", new { id = feature.ProductId }); } else { return View(vm); } }
public ActionResult Create(int productId) { var vm = new ProductFeatureViewModel { ProductId = productId }; return View(vm); }
public ActionResult Edit(ProductFeatureViewModel vm) { if (ModelState.IsValid) { var feature = service.GetById(vm.Id); if (feature == null) { return new HttpNotFoundResult(); } else { converter.ViewmodelToEntity(vm, ref feature); service.Update(feature); return RedirectToAction("Edit", "Product", new { id = feature.Product.Id }); } } else { return View(vm); } }