public IActionResult Delete(Guid id)
 {
     try
     {
         if (_service.HasChildren(id))
         {
             return(Json(new
             {
                 Result = "Faild",
                 Message = "Please delete the subordinate categories first!"
             }));
         }
         else
         {
             _service.Delete(id);
             return(Json(new
             {
                 Result = "Success"
             }));
         }
     }
     catch (Exception ex)
     {
         return(Json(new
         {
             Result = "Faild",
             Message = ex.Message
         }));
     }
 }
Пример #2
0
        public async Task <JsonResult> Delete(string id, string userId)
        {
            var result = await _categoryAppService.Delete(id, userId);

            OutputModel outputModel = new OutputModel();

            outputModel.Data = result;
            return(new JsonResult(outputModel));
        }
Пример #3
0
        public IActionResult Delete([FromBody] CategoryViewModel model)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest());
            }

            var categoryViewModel = _categoryAppService.Delete(model.Id);

            return(Ok(categoryViewModel));
        }
Пример #4
0
 public ActionResult Delete(Guid id)
 {
     try
     {
         _categoryService.Delete(id, _currentUser.CurrentUserId);
         return(Json(1, JsonRequestBehavior.AllowGet));
     }
     catch (Exception)
     {
         return(Json(-1, JsonRequestBehavior.AllowGet));
     }
 }
Пример #5
0
        public ActionResult Delete(long id)
        {
            try
            {
                //Delete
                _categoryService.Delete(id);

                //Successfully message
                this.AddToastMessage(string.Format(Messages.RecordDeletedSuccessfully, "category"), ToastType.Success);
            }
            catch (CustomException ex)
            {
                this.AddToastMessage(ex.Message, ToastType.Error);
            }
            catch (Exception ex)
            {
                this.AddToastMessage(Messages.GeneralError, ToastType.Error);
            }

            return(RedirectToAction("Index"));
        }
Пример #6
0
 public IActionResult Delete(Guid id)
 {
     _categoryAppService.Delete(id);
     return(Response());
 }
Пример #7
0
 public IActionResult DeleteConfirmed(Guid id)
 {
     _categoryAppService.Delete(id);
     return(RedirectToAction("Index"));
 }