Exemple #1
0
        public override string Execute()
        {
            if (!(AutoConfirm || Console.GetYesNo($"Are you sure you want to remove user {User} from project {Project}?", false)))
            {
                return(string.Empty);
            }

            Console.WriteLine($"Trying to remove {User} from project {Project}...");

            string message = string.Empty;

            var project = _projectService.GetProjectByName(Project).Result;
            var user    = _accountService.GetUserByUserName(User).Result;

            if (project != null && user != null)
            {
                var projectMember = _projectMemberService.GetProjectMemberByUserId(project.Id, int.Parse(user.Id)).Result;

                if (projectMember != null)
                {
                    _projectMemberService.RemoveProjectMember(project.Id, projectMember.Id).Wait();
                    message = $"User {User} has been removed from project {Project}";
                    Logger.LogInformation(message);
                    return(message);
                }
            }
            else
            {
                message = $"Failed to remove user {User}. Make sure the project name and user email are correct.";
            }

            return(message);
        }
        public override string Execute()
        {
            Console.WriteLine($"Trying to update the role of {User} in project {Project}...");

            string message;

            var project = _projectService.GetProjectByName(Project).Result;
            var user    = _accountService.GetUserByUserName(User).Result;
            var roleId  = MemberRole.GetMemberRoleId(Role);

            if (project != null && user != null && roleId > 0)
            {
                var projectMember = _projectMemberService.GetProjectMemberByUserId(project.Id, int.Parse(user.Id)).Result;

                if (projectMember != null)
                {
                    _projectMemberService.UpdateProjectMember(project.Id, projectMember.Id, new UpdateProjectMemberDto
                    {
                        Id     = projectMember.Id,
                        UserId = int.Parse(user.Id),
                        ProjectMemberRoleId = roleId
                    }).Wait();

                    message = $"User {User} has been assigned as {Role} in project {Project}";
                    Logger.LogInformation(message);
                    return(message);
                }
            }

            message = $"Failed to update user {User}. Make sure the project name and user email are correct.";

            return(message);
        }
Exemple #3
0
        public async Task <IActionResult> GetProjectMemberByUserId(int projectId, int userId)
        {
            _logger.LogInformation("Getting member for user {userId} in project {projectId}", userId, projectId);

            var projectMember = await _projectMemberService.GetProjectMemberByUserId(projectId, userId);

            var result = _mapper.Map <ProjectMemberDto>(projectMember);

            return(Ok(result));
        }
Exemple #4
0
        public async Task <IActionResult> GetProjectMemberByUserId(int projectId, int userId)
        {
            _logger.LogRequest("Getting member for user {userId} in project {projectId}", userId, projectId);

            var projectMember = await _projectMemberService.GetProjectMemberByUserId(projectId, userId);

            var result = _mapper.Map <ProjectMemberDto>(projectMember);

            _logger.LogResponse("Member with user id {userId} in project {projectId} retrieved. Response body: {@result}", userId, projectId, result);

            return(Ok(result));
        }