Exemple #1
0
        public async Task <IActionResult> GetRequestById(int requestId)
        {
            RequestData requestResult = await _requestGateway.GetRequestById(requestId);

            if (requestResult == null)
            {
                return(BadRequest("Request not found"));
            }

            if (!HttpContext.User.IsInRole("admin"))
            {
                EnumProjectAccessRight projectAccessRight = await _getAccessUser.GetUserAccessRightProject(Convert.ToInt32(HttpContext.User.FindFirstValue(ClaimTypes.NameIdentifier)), requestResult.ProjectId);

                if (projectAccessRight == EnumProjectAccessRight.None)
                {
                    ProjectIsPublic projectIsPublic = await _projectGateway.ProjectIsPublic(requestResult.ProjectId);

                    if (projectIsPublic.IsPublic == 1)
                    {
                        return(StatusCode(403, "Access Denied !"));
                    }
                }
            }

            return(Ok(requestResult));
        }
Exemple #2
0
        public async Task <IActionResult> SaveSearchData(int requestId, [FromBody] StringViewModel resultJson)
        {
            // on change le status request on le met à 3
            await _requestGateway.ChangeStatusRequest(requestId, 3);

            // recup le project Id
            RequestData request = await _requestGateway.GetRequestById(requestId);

            // Verifier que le noeud existe tjrs
            if (_dGraphGateway.NodeExists(request.ProjectId, request.UidNode))
            {
                List <NodeSearchData>     nodesSearchData = JsonConvert.DeserializeObject <List <NodeSearchData> >(resultJson.Key);
                List <AddNodesToNodeData> nodes           = await _dGraphGateway.CreateAddNodesToNodeData(request.ProjectId, request.Author, request.UidNode, nodesSearchData);

                await _dGraphGateway.AddNodesToNode(request.ProjectId, request.UidNode, nodes);

                _requestGateway.DeleteRequest(requestId);

                FluentResults.Result <string> resultNodes = await _dGraphGateway.FindByProjectId(request.ProjectId);

                // On envoit message à tous les gens du projet
                string nameProject = await GetProjectName(request.ProjectId);

                IEnumerable <string> userInProject = await _projectGateway.GetIdUserInProject(request.ProjectId);

                await _graphHub.ReceiveRequestDoneGiveNewNode(userInProject.ToList(), resultNodes.Value, request.DataEntity);

                await _projectHub.ReceiveRequestDone(userInProject.ToList(), Convert.ToString(request.ProjectId), request.DataEntity, nameProject);
            }

            return(Ok("Request done"));
        }