コード例 #1
0
        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);
            }
        }
コード例 #2
0
 public ActionResult Create(int productId)
 {
     var vm = new ProductFeatureViewModel { ProductId = productId };
     return View(vm);
 }
コード例 #3
0
        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);
            }
        }