예제 #1
0
        public async Task <IActionResult> GetProjectById(int projectId)
        {
            Result <ProjectData> result = await _projectGateway.GetProjectById(projectId);

            if (result.ErrorMessage == "Project not found")
            {
                return(BadRequest(result.ErrorMessage));
            }

            EnumProjectAccessRight projectAccessRight = await _getAccessUser.GetUserAccessRightProject(Convert.ToInt32(HttpContext.User.FindFirstValue(ClaimTypes.NameIdentifier)), projectId);

            if (!HttpContext.User.IsInRole("admin") && projectAccessRight == EnumProjectAccessRight.None && result.Content.IsPublic == 0)
            {
                return(StatusCode(403, "Access Denied !"));
            }

            return(Ok(result.Content));
        }
예제 #2
0
        public async Task <IActionResult> GetProjectGraphById(int projectId)
        {
            Result <ProjectData> result = await _projectGateway.GetProjectById(projectId);

            if (result.ErrorMessage == "Project not found")
            {
                return(BadRequest(result.ErrorMessage));
            }

            bool userCanReadProject = await UserCanReadProject(projectId, result.Content);

            if (!userCanReadProject)
            {
                return(StatusCode(403, "Access Denied !"));
            }

            FluentResults.Result <string> resultGraphByProjectId = await _dGraphGateway.FindByProjectId(projectId);

            return(Ok(resultGraphByProjectId.Value));
        }