Beispiel #1
0
        public async Task <string> GetComments([FromQuery] int postid)
        {
            if (!User.Identity.IsAuthenticated)
            {
                return(ControllersServices.ErrorMessage("auth"));
            }

            var result = await _context.GetCommentAsync(postid);

            if (result != null)
            {
                return(JsonConvert.SerializeObject(new { CommentsList = result }));
            }
            else
            {
                return(ControllersServices.ErrorMessage("Can't add new comment, sorry."));
            }
        }