Exemplo n.º 1
0
        public ActionResult Edit(ProductViewData productViewData)
        {
            var product = productBuilder.ProductFromProductViewData(productViewData, ModelState, Request);

            if (ModelState.IsValid)
            {
                return(this.RedirectToAction(x => x.Edit(product.Id)));
            }
            return(View("Edit", productViewData.WithErrorMessage("There were errors, please correct them and resubmit.")));
        }
Exemplo n.º 2
0
        public ActionResult New(ProductViewData productViewData)
        {
            var product = productBuilder.ProductFromProductViewData(productViewData, ModelState, Request);

            if (ModelState.IsValid)
            {
                productRepository.SaveOrUpdate(product);
                uow.Commit();                 //Need explicit commit in order to get the product id.
                return(this.RedirectToAction(x => x.Edit(product.Id)));
            }
            return(View("Edit", productViewData.WithErrorMessage("There were errors, please correct them and resubmit.")));
        }