Esempio n. 1
0
        public async Task <IActionResult> Edit(int productId, [Bind("Code,Name,Photo,Price")]
                                               ProductUpdateRequestModel productUpdateRequestModel)
        {
            if (ModelState.IsValid)
            {
                await _productCatalogService.UpdateProduct(productId, productUpdateRequestModel);
            }

            return(RedirectToAction("Index"));
        }
        public async Task <ActionResult> Edit(Guid id, EditProductViewModel editProductViewModel)
        {
            try
            {
                await _service.UpdateProduct(id, ProductFactory.Make(editProductViewModel));

                return(RedirectToAction(nameof(Index)));
            }
            catch (Exception exc)
            {
                return(View("Error", new ErrorViewModel {
                    RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier, Description = exc?.Message
                }));
            }
        }