Beispiel #1
0
        public async Task <IActionResult> OnPostAsync(int userid)
        {
            try
            {
                posts.UserId = userid;

                posts.BoardId = await _boardsServices.CreateBoard(Board);

                postId = await _postsServices.CreatePost(posts);

                return(RedirectToPage("PostDetails", new { id = postId }));
            }
            catch (Exception)
            {
                return(RedirectToPage("../Error"));
            }
        }
Beispiel #2
0
        public ActionResult <ItemResponse <int> > CreatePost(PostAddRequest req)
        {
            ActionResult       result   = null;
            ItemResponse <int> response = null;

            try
            {
                int newPostId = _postService.CreatePost(req);
                response      = new ItemResponse <int>();
                response.Item = newPostId;
                result        = Ok(response.Item);
            }
            catch (Exception ex)
            {
                result = StatusCode(500, new ErrorResponse(ex.Message.ToString()));
            }

            return(result);
        }