public async Task <string> Import([FromQuery] int type)
        {
            var context = await ControllersServices.GetJsonFromBodyRequestAsync(Request.Body);

            var isParsed = TryDeserialize(context, type);

            if (!isParsed)
            {
                return("false");
            }

            return("true");
        }
Esempio n. 2
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."));
            }
        }