Esempio n. 1
0
        //[HttpPost]
        //[ValidateAntiForgeryToken]
        //public IActionResult EditProduct(Product data)
        //{
        //    try
        //    {
        //        if (ModelState.IsValid)
        //        {
        //            _repository.UpdateProduct(data);
        //            return RedirectToAction("Products");
        //        }
        //        return View(data);
        //    }
        //    catch (Exception ex)
        //    {
        //        return View("Error", ex);
        //    }
        //}

        public IActionResult DeleteProduct(int productId)
        {
            try
            {
                _repository.DeleteProduct(productId);
                return(RedirectToAction("Products"));
            }
            catch (Exception ex)
            {
                return(View("Error", ex));
            }
        }