Ejemplo n.º 1
0
        public async Task <HttpResponseMessage> CreateRoleAssignment(int projectId, [FromBody] RoleAssignmentDTO roleAssignment)
        {
            if (roleAssignment == null)
            {
                throw new BadRequestException(ErrorMessages.ModelIsEmpty, ErrorCodes.BadRequest);
            }

            await _privilegesManager.DemandAny(Session.UserId, projectId,
                                               InstanceAdminPrivileges.AccessAllProjectsAdmin, ProjectAdminPrivileges.ManageGroupsAndRoles);

            RoleAssignmentValidator.ValidateModel(roleAssignment);

            var createdRoleAssignmentId = await _instanceRepository.CreateRoleAssignmentAsync(projectId, roleAssignment);

            return(Request.CreateResponse(HttpStatusCode.Created, createdRoleAssignmentId));
        }