public ActionResult <ItemsResponse <Post> > GetPosts() { ActionResult result = null; ItemsResponse <Post> response = null; try { List <Post> postList = _postService.GetPosts(); if (postList != null) { response = new ItemsResponse <Post>(); response.Items = postList; result = Ok(response.Items); } else { result = NotFound(new ErrorResponse("404 not found.")); } } catch (Exception ex) { result = StatusCode(500, new ErrorResponse(ex.Message.ToString())); } return(result); }
public async Task <IActionResult> OnGetAsync() { try { Posts = await _postsServices.GetPosts(); Boards = await _boardsServices.GetBoards(); return(Page()); } catch (Exception) { return(RedirectToPage("../Error")); } }