Пример #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));
        }