Exemple #1
0
        public async Task <IActionResult> result(PlagiarismCheckingMeta dto)  // PlagiarismCheckingMeta dto
        {
            try {
                var    BearerToken = Request.Headers["Authorization"];                      // get the bearer token
                string tokenStr    = BearerToken.ToString().Split(" ")[1].ToString();       // separate bearer part from token, and only retrieve the token
                string uid         = _deserializeToken.deserializedToken(tokenStr).user_id; // get the user id of the authenticated user.

                if (!(await _auth.UserExist(uid, tokenStr)))
                {
                    return(BadRequest("User doesn't exist"));
                }

                string XMLResult = await _plagiarismChecking.plagiarismResult(dto.content, dto.depth);

                string jsonResult = _xMLtoJSON.getJson(XMLResult);

                return(Ok(jsonResult));
            } catch (Exception error) {
                return(BadRequest(error.Message));
            }
        }