コード例 #1
0
ファイル: CategoryController.cs プロジェクト: ankaada09/Post
 public ActionResult Delete(int id)
 {
     try
     {
         _deleteCategory.Execute(id);
         return(NoContent());
     }
     catch (Exception)
     {
         return(StatusCode(500));
     }
 }
コード例 #2
0
 public IActionResult Delete(int id)
 {
     try
     {
         _deleteCategory.Execute(id);
         return(StatusCode(204));
     }
     catch (NotFoundException)
     {
         return(NotFound());
     }
 }
コード例 #3
0
ファイル: CategoryController.cs プロジェクト: ankaada09/Post
 // GET: Category/Delete/5
 public IActionResult  Delete(int id)
 {
     try
     {
         _deleteCategory.Execute(id);
         return(RedirectToAction(nameof(Index)));
     }
     catch (Exception)
     {
         return(RedirectToAction("index"));
     }
 }
コード例 #4
0
 // GET: User/Delete/5
 public ActionResult Delete(int id)
 {
     try
     {
         _deleteCategory.Execute(id);
         return(RedirectToAction(nameof(Index)));
     }
     catch (Exception)
     {
         TempData["error"] = "Some error occurred. Please try again.";
         return(RedirectToAction(nameof(Index)));
     }
 }
コード例 #5
0
 public ActionResult <IEnumerable <CategoryDTO> > Delete(CategoryDTO dto)
 {
     try
     {
         _deleteCommand.Execute(dto);
         return(NoContent());
     }
     catch (EntityNotFoundException)
     {
         return(NotFound());
     }
     catch (Exception)
     {
         return(StatusCode(500));
     }
 }
コード例 #6
0
 public ActionResult Delete(int id, CategoryDto dto)
 {
     try
     {
         _deleteCommand.Execute(id);
         return(RedirectToAction(nameof(Index)));
     }
     catch (EntityDeleted) {
         TempData["error"] = "This category is already deleted";
         return(View());
     }
     catch (Exception)
     {
         return(View());
     }
 }
コード例 #7
0
 public ActionResult Delete(int id)
 {
     try
     {
         deleteCategoryCommand.Execute(id);
         return(NoContent());
     }
     catch (DataNotFoundException)
     {
         return(NotFound());
     }
     catch (Exception)
     {
         return(StatusCode(500));
     }
 }
コード例 #8
0
 public ActionResult Delete(int id)
 {
     try
     {
         _deleteCategoryCommand.Execute(id);
         return(NoContent());
     }
     catch (EntityNotFoundException e)
     {
         return(NotFound(e.Message));
     }
     catch (Exception e)
     {
         return(StatusCode(StatusCodes.Status500InternalServerError, e.Message));
     }
 }
 public IActionResult Delete(int id)
 {
     try
     {
         _deleteCommand.Execute(id);
         return(NoContent());
     }
     catch (EntityNotFoundException)
     {
         return(NotFound("Ne psotoji objekat"));
     }
     catch (Exception)
     {
         return(StatusCode(500, "Doslo je do greske"));
     }
 }
コード例 #10
0
 public ActionResult Delete(int id, CategoryDTO category)
 {
     try
     {
         _deleteCategoryCommand.Execute(category);
         return(RedirectToAction(nameof(Index)));
     }
     catch (EntityNotFoundException)
     {
         return(View());
     }
     catch (Exception)
     {
         return(RedirectToAction("index"));
     }
 }
コード例 #11
0
        // GET: Categories/Delete/5

        public ActionResult Delete(int id)
        {
            try
            {
                deleteCategoryCommand.Execute(id);
                return(RedirectToAction("Index"));
            }
            catch (DataNotFoundException)
            {
                return(null);
            }
            catch (Exception)
            {
                return(RedirectToAction("Create"));
            }
        }
コード例 #12
0
 public ActionResult Delete(int id)
 {
     try
     {
         _deleteCommand.Execute(id);
         return(NoContent());
     }
     catch (EntityNotFoundException e)
     {
         return(NotFound(e.Message));
     }
     catch (Exception)
     {
         return(StatusCode(500, "Server error has occurred."));
     }
 }
コード例 #13
0
        public IActionResult Delete(int id)
        {
            try
            {
                _deleteCategoryCommand.Execute(id);
                return(NoContent());
            }
            catch (EntityNotFoundException e)
            {
                if (e.Message == "Category doesn't exist.")
                {
                    return(NotFound(e.Message));
                }

                return(UnprocessableEntity(e.Message));
            }
        }
コード例 #14
0
        public ActionResult Delete(int id)
        {
            try
            {
                _deleteCategoryCommand.Execute(id);
                TempData["success"] = "Category deleted.";
            }
            catch (EntityNotFoundException e)
            {
                TempData["error"] = e.Message;
            }
            catch (Exception e)
            {
                TempData["error"] = e.Message;
            }

            return(RedirectToAction(nameof(Index)));
        }
コード例 #15
0
 public ActionResult Delete(int id, CategoryDto dto)
 {
     try
     {
         _deleteCommand.Execute(id);
         return(RedirectToAction("Index"));
     }
     catch (EntityNotFoundException)
     {
         TempData["error"] = "Category doesn't exist.";
         return(RedirectToAction(nameof(Index)));
     }
     catch (Exception)
     {
         TempData["error"] = "Error";
         return(RedirectToAction(nameof(Index)));
     }
 }
コード例 #16
0
 public IActionResult Delete(int id)
 {
     // 505
     try
     {
         _deleteCommand.Execute(id);
         return(NoContent());
     }
     catch (EntityNotFoundException)
     {
         return(NotFound());
     }
     catch (EntityDeleted)
     {
         return(StatusCode(410, "The Category is already Deleted"));
     }
     catch (Exception)
     {
         return(StatusCode(500, "An error occured."));
     }
 }