コード例 #1
0
        public async Task <IActionResult> DeleteArticle(int id)
        {
            var deleted = await _deleteCommand.Execute(id);

            if (deleted)
            {
                return(Ok());
            }

            return(BadRequest("Failed to delete article"));
        }
コード例 #2
0
        public async Task <IActionResult> DeleteArticle(int id)
        {
            await _deleteCommand.Execute(id);

            return(Ok());

            // TODO: handle errors

            //if (await _unitOfWork.Commit())
            //    return Ok();

            //return BadRequest("Failed to delete article");
        }
コード例 #3
0
        public ActionResult Delete(int id)
        {
            try
            {
                _deleteArticleCommand.Execute(id);
                TempData["success"] = "Article deleted.";
            }
            catch (EntityNotFoundException e)
            {
                TempData["error"] = e.Message;
            }
            catch (Exception e)
            {
                TempData["error"] = e.Message;
            }

            return(RedirectToAction(nameof(Index)));
        }