public IActionResult Delete(int id)
        {
            var product = _query.GetById(id);

            if (product.ProductImage != null)
            {
                var imagePath = Path.Combine(_hostEnvironment.WebRootPath, "image", product.ProductImage);
                if (System.IO.File.Exists(imagePath))
                {
                    System.IO.File.Delete(imagePath);
                }
            }
            _command.Delete(product);
            return(RedirectToAction("List"));
        }
Esempio n. 2
0
        public async Task <IActionResult> ConfirmDelete(int id)
        {
            await _product.Delete(id);

            return(Redirect("/"));
        }