public HttpResponseMessage Delete(int id)
        {
            CategoriesRepository.DeleteCategory(id);
            HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.OK, "Deleted");

            return(response);
        }
Example #2
0
        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);
        }
Example #3
0
        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);
 }
Example #6
0
 public bool DeleteCategory(int categoryID)
 {
     return(CategoriesRepository.DeleteCategory(categoryID));
 }
Example #7
0
 public void DeleteCategory(int cID)
 {
     cr.DeleteCategory(cID);
 }