public async Task <IActionResult> RemoveTeamMember([BindRequired] long?projectId, [BindRequired] long?teamMemberId) { if (!ModelState.IsValid) { return(RedirectToAction(nameof(Details), new { projectId = projectId.Value })); } var removeTeamMemberRequest = new RemoveProjectTeamMemberRequest { ProjectId = projectId.Value, TeamMemberId = teamMemberId.Value }; await _projectApplicationService.Handle(removeTeamMemberRequest); return(RedirectToAction(nameof(Details), new { projectId = projectId.Value })); }
public async Task <UserResponse> Handle(RemoveProjectTeamMemberRequest request) { var project = await _projectRepository.ReadById(request.ProjectId); if (project == default) { throw new ArgumentNullException("Project not found"); } var teamMember = project.TeamMembers.FirstOrDefault(user => user.Id == request.TeamMemberId); if (teamMember == default) { throw new ArgumentNullException("User with id not found"); } project.RemoveTeamMember(teamMember); await _projectRepository.PersistChanges(); return(teamMember.Adapt <UserResponse>()); }