Ejemplo n.º 1
0
        public async Task <IActionResult> DeleteProject(int projectId)
        {
            EnumProjectAccessRight projectAccessRight = await _getAccessUser.GetUserAccessRightProject(Convert.ToInt32(HttpContext.User.FindFirstValue(ClaimTypes.NameIdentifier)), projectId);

            if (!HttpContext.User.IsInRole("admin") && projectAccessRight != EnumProjectAccessRight.Admin)
            {
                return(StatusCode(403, "Access Denied !"));
            }

            _dGraphGateway.DeleteProject(projectId);
            Result result = await _projectGateway.DeleteProject(projectId);

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

            return(Ok("Project has been deleted"));
        }