Ejemplo n.º 1
0
        public ActionResult Edit(ProductEditModel model)
        {
            if (ModelState.IsValid)
            {
                var product = model.AsProduct();
                PopulateProduct(model, product);

                repository.Update(product);

                return(RedirectToAction("Index"));
            }

            return(View(model));
        }
Ejemplo n.º 2
0
        public ActionResult Create([Bind(Exclude = "Id")] ProductEditModel model)
        {
            if (ModelState.IsValid)
            {
                var product = model.AsProduct();
                product.Id = repository.All().Last().Id + 1;
                PopulateProduct(model, product);

                repository.Add(product);

                return(RedirectToAction("Index"));
            }

            return(View(model));
        }