Esempio n. 1
0
        public async Task <IActionResult> AddComment([FromBody] Comments comment)
        {
            Comments newcomment = new Comments();

            newcomment.Body           = comment.Body;
            newcomment.Pageid         = comment.Pageid;
            newcomment.CreatedBy      = comment.CreatedBy;
            newcomment.CreatedAt      = newcomment.CreatedAt;
            newcomment.IsMarkedAsSpam = false;

            var result = await _postService.AddNewComment(newcomment);

            return(Ok(1));
        }
        public async Task <IActionResult> AddNewComment(int postId, string text)
        {
            AppUser user = await userManager.GetUserAsync(User);

            try
            {
                await postService.AddNewComment(postId, text, user.Alias);

                return(Json(new { alias = user.Alias }));
            }
            catch (ArgumentException)
            {
                return(Json(new { error = "Anon users can't send comments" }));
            }
        }