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

            var context = await ControllersServices.GetJsonFromBodyRequestAsync(Request.Body);

            var result = await _context.AddNewCommentAsync(postid, User.Identity.Name, context);

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