public void ViewModelToEntity_EntityIdNotPreset_ThrowsException() { var vm = new ProductVersionViewModel { Id = 1, Major = "1", Minor = "1", Build = "1", Patch = "1" }; }
public ActionResult Create(ProductVersionViewModel vm) { if (ModelState.IsValid) { var version = new ProductVersion { ProductId = vm.ProductId }; converter.ViewmodelToEntity(vm, ref version); service.Add(version); return RedirectToAction("Edit", "Product", new { id = version.ProductId }); } else { return View(vm); } }
public ActionResult Create(int productId) { var vm = new ProductVersionViewModel { ProductId = productId }; return View(vm); }
public ActionResult Edit(ProductVersionViewModel vm) { if (ModelState.IsValid) { var version = service.GetById(vm.Id); if (version == null) { return new HttpNotFoundResult(); } else { converter.ViewmodelToEntity(vm, ref version); service.Update(version); return RedirectToAction("Edit", "Product", new { id = version.Product.Id }); } } else { return View(vm); } }