Exemple #1
0
        public async Task <IActionResult> PostNewThread([FromBody] ThreadModel body, [FromHeader] string token)
        {
            if (!body.IsValidThread())
            {
                return(new NotFoundObjectResult("Invalid body"));
            }

            await Db.Connection.OpenAsync();

            //check that user is logged in
            if (await authorizationQuery.GetTokenModel(token) != null)
            {
                //return 200 if thread is successfully added
                if (await postQuery.AddThread(body))
                {
                    return(new OkResult());
                }

                return(new NotFoundObjectResult("Could not add thread"));
            }

            return(new NotFoundObjectResult("User must be logged in to add thread"));
        }