// DELETE: api/SubCategory/5
 public bool Delete(int id)
 {
     if (id > 0)
     {
         return(_subCategoryService.DeleteSubCategory(id));
     }
     return(false);
 }
 public IActionResult DeleteSubCategory([FromBody] SubCategory subCategory)
 {
     if (ModelState.IsValid)
     {
         _subCategoryService.DeleteSubCategory(subCategory);
     }
     return(Ok());
 }
 public async Task <IActionResult> Delete(int id)
 {
     if (id == 0)
     {
         return(NotFound());
     }
     if (await subCategoryService.DeleteSubCategory(id))
     {
         return(RedirectToAction(nameof(Index)));
     }
     return(View());
 }
 public IActionResult Delete(int id)
 {
     try
     {
         _subCategoryService.DeleteSubCategory(id);
         return(Ok());
     }
     catch (Exception)
     {
         return(BadRequest("Subcategory not found"));
     }
 }
        public IActionResult DeleteSubCategory(int id)
        {
            var result = _subCatSrv.DeleteSubCategory(id);

            if (result > 0)
            {
                return(Ok(new { Status = "Success" }));
            }
            else
            {
                return(Ok(new { Status = "Failed" }));
            }
        }
Exemple #6
0
        public ActionResult <SubCategoryDto> DeleteSubCategory(int id)
        {
            var subCategoryDto = _subCategoryService.DeleteSubCategory(id);

            if (subCategoryDto == null)
            {
                List <string> errorMessage = new List <string>();
                errorMessage.Add("Đã phát sinh lỗi, vui lòng thử lại");
                return(BadRequest(new ResponseDto(errorMessage, 500, "")));
            }
            List <string> successMessage = new List <string>();

            successMessage.Add("Xoá thành công");
            var responseDto = new ResponseDto(successMessage, 200, "");

            return(Ok(responseDto));
        }
Exemple #7
0
        public ActionResult DeleteSubCategory(int subCategoryId)
        {
            if (!_workContext.CurrentCustomer.IsRegistered())
            {
                return(Unauthorized());
            }


            if (!_workContext.CurrentCustomer.IsInCustomerRole(RolesType.Administrators, true) && !_workContext.CurrentCustomer.IsInCustomerRole(RolesType.ConsultationAdmin, true))
            {
                return(Forbid());
            }

            if (subCategoryId == null || subCategoryId == 0)
            {
                return(NotFound());
            }

            _subCategory.DeleteSubCategory(subCategoryId);

            return(Json(new { result = true }));
        }
Exemple #8
0
        public ActionResult DeleteSubCategory(string Id)
        {
            var res = _subCategoryService.DeleteSubCategory(Convert.ToDecimal(Id));

            return(Json(true, JsonRequestBehavior.AllowGet));
        }