Exemplo n.º 1
0
 public ActionResult DeleteConfirmed(int id)
 {
     if (_categoryService.GetByImg(id) != null)
     {
         _categoryService.RemoveImage(id);
         _imageService.Delete(id);
         return(RedirectToAction("Index", "Categories"));
     }
     if (_subcategoryService.GetByImg(id) != null)
     {
         int catId = _subcategoryService.GetByImg(id).CategoryID;
         _subcategoryService.RemoveImage(id);
         _imageService.Delete(id);
         return(RedirectToAction("IndexAdmin", "Subcategories", new { id = catId }));
     }
     if (_makerService.GetByImg(id) != null)
     {
         _makerService.RemoveImage(id);
         _imageService.Delete(id);
         return(RedirectToAction("Index", "Makers"));
     }
     if (_productService.GetByImg(id) != null)
     {
         int subcatId = _productService.GetByImg(id).SubcategoryID;
         _productService.RemoveImage(id);
         _imageService.Delete(id);
         return(RedirectToAction("Index", "Products", new { subcatId = subcatId }));
     }
     return(RedirectToAction("Index"));
 }