public ActionResult DeleteCategory(int categoryid) { try { var category = _repo.GetCategoryByID(categoryid).ToList(); var listing = _repo.GetListingByCategoryId(categoryid).ToList(); _repo.RemoveCategory(categoryid); _repo.Save(); SetImmageFile setImageFile = new SetImmageFile(); setImageFile.DeleteImageFile(category[0].image, this.HttpContext); foreach (var items in listing) { setImageFile.DeleteImageFile(items.image, this.HttpContext); } return(Json(new { success = true })); } catch { return(RedirectToAction("Index")); } }
public ActionResult DeleteListing(int listingid, int categoryid, string categoryname) { try { var listing = _repo.GetListingById(listingid).ToList(); _repo.RemoveListing(listingid); _repo.Save(); SetImmageFile setImageFile = new SetImmageFile(); setImageFile.DeleteImageFile(listing[0].image, this.HttpContext); return(Json(new { success = true })); } catch { return(RedirectToAction("GetCategoryListings", new { categoryid = categoryid, categoryname = categoryname })); } }
public ActionResult DeleteListing(int listingid, int categoryid, string categoryname) { try { var listing = _repo.GetListingById(listingid).ToList(); _repo.RemoveListing(listingid); _repo.Save(); SetImmageFile setImageFile = new SetImmageFile(); setImageFile.DeleteImageFile(listing[0].image, this.HttpContext); return Json(new { success = true }); } catch { return RedirectToAction("GetCategoryListings", new { categoryid = categoryid, categoryname = categoryname }); } }
public ActionResult DeleteCategory(int categoryid) { try { var category = _repo.GetCategoryByID(categoryid).ToList(); var listing = _repo.GetListingByCategoryId(categoryid).ToList(); _repo.RemoveCategory(categoryid); _repo.Save(); SetImmageFile setImageFile = new SetImmageFile(); setImageFile.DeleteImageFile(category[0].image, this.HttpContext); foreach (var items in listing) { setImageFile.DeleteImageFile(items.image, this.HttpContext); } return Json(new { success = true }); } catch { return RedirectToAction("Index"); } }