public HttpResponseMessage Delete(int id) { CategoriesRepository.DeleteCategory(id); HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.OK, "Deleted"); return(response); }
public Category DeleteCategory(string id) { var categoryQuestion = _repo.GetCategoryQuestion(id); if (categoryQuestion != null) { throw new Exception("Unable to delete categories that have been added to queestions."); } var category = GetCategoryById(id); var deleted = _repo.DeleteCategory(id); if (!deleted) { throw new Exception($"Unable to delete category ID: {id}"); } return(category); }
public ActionResult DeleteConfirmed(int id) { Category category = _categoriesRepository.FindCategoryById(id); if (category != null) { ViewBag.SelectedNav = "Dashboard"; if (category.JobListings.Count() < 1) { _categoriesRepository.DeleteCategory(category); return(RedirectToAction(nameof(Index))); } else { TempData["ErrorMessage"] = $"Category '{category.Name}' has active job listings and cannot be deleted."; return(RedirectToAction(nameof(Index))); } } ViewBag.SelectedNav = "Dashboard"; return(RedirectToAction(nameof(Index))); }
/// <summary> /// Deletes a category /// Level: Logic /// </summary> /// <param name="CategoryID">The category id</param> /// <returns>True if deleted, false if not deleted</returns> public bool DeleteCategory(int CategoryID) { try { CategoriesRepository myRepository = new CategoriesRepository(); if ((!myRepository.CheckForSubCategories(CategoryID)) && (!myRepository.CheckForAssignedProducts(CategoryID))) { myRepository.DeleteCategory(CategoryID); return(true); } else { return(false); } } catch (Exception Exception) { throw Exception; } }
public void DeleteCategory(int id) { _categoriesRepo.DeleteCategory(id); }
public bool DeleteCategory(int categoryID) { return(CategoriesRepository.DeleteCategory(categoryID)); }
public void DeleteCategory(int cID) { cr.DeleteCategory(cID); }