Exemplo n.º 1
0
 // GET: Posts/Details/5
 public ActionResult Details(int id)
 {
     try
     {
         var dto = _getOnePost.Execute(id);
         return(View(dto));
     }
     catch (Exception)
     {
         return(View());
     }
 }
Exemplo n.º 2
0
 // GET: Posts/Details/5
 public ActionResult Details(int id)
 {
     try
     {
         var post = _getOneCommand.Execute(id);
         return(View(post));
     }
     catch (EntityNotFoundException)
     {
         return(RedirectToAction(nameof(Index)));
     }
     catch (Exception)
     {
         TempData["error"] = "Server error has occurred.";
         return(RedirectToAction(nameof(Index)));
     }
 }
Exemplo n.º 3
0
 // GET: Posts/Details/5
 public ActionResult Details(int id)
 {
     try
     {
         var dto = _getPost.Execute(id);
         return(View(dto));
     }
     catch (NotFoundException)
     {
         TempData["error"] = "There is no post with that id.";
         return(RedirectToAction(nameof(Index)));
     }
     catch (Exception)
     {
         TempData["error"] = "Something went wrong. Please try again.";
         return(View());
     }
 }
Exemplo n.º 4
0
 public IActionResult Get(int id)
 {
     try
     {
         return(Ok(_getPostCommand.Execute(id)));
     }
     catch (EntityNotFoundException)
     {
         return(NotFound());
     }
 }
Exemplo n.º 5
0
 public ActionResult <IEnumerable <PostDTO> > Get(int id)
 {
     try
     {
         var postDTO = _getOneCommand.Execute(id);
         return(Ok(postDTO));
     }
     catch (EntityNotFoundException)
     {
         return(NotFound());
     }
 }
Exemplo n.º 6
0
 public ActionResult <GetPostDto> Get(int id)
 {
     try
     {
         var post = _getOne.Execute(id);
         return(StatusCode(200, post));
     }
     catch (EntityNotFoundException e)
     {
         return(NotFound(e.Message));
     }
     catch (Exception e)
     {
         return(StatusCode(500, e.Message));
     }
 }
Exemplo n.º 7
0
 public ActionResult Get(int id)
 {
     try
     {
         var post = _getOneCommand.Execute(id);
         return(Ok(post));
     }
     catch (EntityNotFoundException e)
     {
         return(NotFound(e.Message));
     }
     catch (Exception)
     {
         return(StatusCode(500, "Server error has occurred."));
     }
 }
        // GET: Posts/Details/5
        public ActionResult Details(int id)
        {
            var post = _getOne.Execute(id);

            return(View(post));
        }
Exemplo n.º 9
0
 public IActionResult Get(
     [FromServices] IGetPostCommand command,
     int id) => command.Execute(id);